shiyang/yii2-masonry

Masonry Yii2 Extension width infinitescroll

Installs: 449

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 4

Open Issues: 1

Type:yii2-extension

v1.0.1 2015-05-02 06:18 UTC

This package is not auto-updated.

Last update: 2025-09-27 22:07:15 UTC


README

Masonry Yii2 Extension width infinitescroll

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist shiyang/yii2-masonry "*"

or add

"shiyang/yii2-masonry": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Controller action:

function actionIndex()
{
    $query = Article::find()->where(['status' => 1]);
    $countQuery = clone $query;
    $pages = new Pagination(['totalCount' => $countQuery->count()]);
    $models = $query->offset($pages->offset)
        ->limit($pages->limit)
        ->all();

    return $this->render('index', [
         'models' => $models,
         'pages' => $pages,
    ]);
}

View:

\shiyang\masonry\Masonry::begin([
        'options' => [
          'id' => 'models'
        ],
        'pagination' => $pages
    ]);
	foreach ($models as $model) {
	    // display $model here
	}
\shiyang\masonry\Masonry::end();