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

News module

Description

News module helps you to create live editable news on frontend.


Include

use yii\easyii\modules\news\api\News;


Public functions

object News::get( $id )
$id integer / string News identifier can be integer (id) or string (slug)

examples

News::get(1);
News::get('news-slug');
stdClass Object
(
    [id] => 1
    [thumb] => "/path/to/image.jpg"
    [title] => "News title"
    [short] => "News short text"
    [text] => "News html text"
    [seo_h1] => "Seo news title"
    [seo_title] => "Seo window title"
    [seo_keywords] => "seo, website, keywords"
    [seo_description] => "Seo description"
    [slug] => "news-slug"
    [views] => 12
    [time] => 1623991356
    [date] => "Jun 18, 2021, 7:42:36 AM"
    [empty] => false
)
IF news with id == 1 exists
stdClass Object
(
    [id] => ""
    [thumb] => ""
    [title] => ""
    [short] => ""
    [text] => ""
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [slug] => ""
    [views] => ""
    [time] => ""
    [date] => ""
    [empty] => true
)
IF news is not exist
stdClass Object
(
    [id] => ""
    [thumb] => ""
    [title] => "WRONG NEWS_ID"
    [short] => "WRONG NEWS_ID"
    [text] => "WRONG NEWS_ID"
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [slug] => ""
    [views] => ""
    [time] => ""
    [date] => ""
    [empty] => true
)
IF news is not exist and user logged in

array News::all( $options = [] )
$options array
  • pageSize (int) - news count on single page
  • where (array) - additional select condition

examples

News::all();
array of news objects

mixed News::last( $limit = 1 )
$limit integer Count of last news

examples

News::last(3);
news object IF limit == 1
array[3] of news objects IF limit > 1

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

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