New version 0.9 has been released! Jun 16, 2015
×

Article module

Description

Article module helps you to create live editable articles with categories on frontend.


Include

use yii\easyii\modules\article\api\Article;


Public functions

object Article::cat( $id, $options = [] )
$id integer / string Category identifier can be integer (id) or string (slug)
$options array
  • pageSize (int) - item count on single page

examples

Article::cat(1);
Article::cat('cat-slug');
stdClass Object
(
    [id] => 1
    [title] => "Category name"
    [seo_h1] => "Seo category title"
    [seo_title] => "Seo window title"
    [seo_keywords] => "seo, website, keywords"
    [seo_description] => "Seo description"
    [slug] => "cat-slug"
    [items] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 1
                    [thumb] => "/path/to/image.jpg"
                    [title] => "Item name"
                    [short] => "Article short text"
                    [text] => "Article long text"
                    [slug] => "article-slug"
                    [views] => 123
                )

        )

    [empty] => false
)
IF category with id == 1 or slug == 'cat-slug' exists
stdClass Object
(
    [id] => ""
    [title] => ""
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [slug] => ""
    [items] => Array
        (
        )

    [empty] => true
)
IF category is not exist
stdClass Object
(
    [id] => ""
    [title] => "<a href="...">Create category</a>"
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [slug] => ""
    [items] => Array
        (
        )

    [empty] => true
)
IF category is not exist and user logged in

array Article::cats( $options = [] )
$options array
  • pageSize (int) - category count on single page
  • where (array) - additional select condition

examples

Article::cats();
array of category objects

object Article::item( $id )
$id integer / string Item identifier can be integer (id) or string (slug)

examples

Article::item(1);
Article::item('article-slug');
stdClass Object
(
    [id] => 1
    [thumb] => "/path/to/image.jpg"
    [title] => "Item name"
    [short] => "Article short text"
    [text] => "Article long text"
    [seo_h1] => "Seo article title"
    [seo_title] => "Seo window title"
    [seo_keywords] => "seo, website, keywords"
    [seo_description] => "Seo description"
    [slug] => "article-slug"
    [views] => 123
)
IF item with id == 1 or slug == 'article-slug' exists
null
IF item is not exist

string Article::pages()
returns pagination html generated by yii\widgets\LinkPager widget.

object Article::pagination()
returns yii\data\Pagination object.