2017 © Pedro Peláez
 

yii2-extension yii2-masonry-view

ListView widget improved to use Masonry (http://masonry.desandro.com/)

image

nerburish/yii2-masonry-view

ListView widget improved to use Masonry (http://masonry.desandro.com/)

  • Tuesday, August 29, 2017
  • by nerburish
  • Repository
  • 3 Watchers
  • 6 Stars
  • 364 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

Yii2 Masonry ListView Widget

Yii2 widget to extend the Yii2 ListView for use it as Masonry grid layout (http://masonry.desandro.com/), (*1)

Widget demo screenshot: masonry-view-demo, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

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

or add, (*5)

"nerburish/yii2-masonry-view": "*"

to the require section of your composer.json file., (*6)

Usage

The usage is similar to default ListView Widget (http://www.yiiframework.com/doc-2.0/yii-widgets-listview.html), (*7)

You just need a dataProvider and prepare the item template for your model., (*8)

In clientOptions you can pass the Masonry options to modify the plugin behavior (see http://masonry.desandro.com/options.html), (*9)

You can also attach a cssFile for styling the grid., (*10)

Exemple

We have this model:, (*11)

class MyModel extends \yii\base\Model
{
    public $id;

    public $title;

    public $description;
}

And this item template named _item.php:, (*12)

<h3><?= $model->title ?></h3>
<p><?= $model->description ?></p>

Finally, in our view, we run the widget:, (*13)

<?php echo \nerburish\masonryview\MasonryView::widget([
    'dataProvider' => $dataProvider,
    'itemView' => '_item',
    'clientOptions' => [
      'gutterWidth' => 15,
    ],
    'cssFile' => [
        "@web/css/masonry-demo.css"     
    ]
]) ?>

Below, the css used for the demo:, (*14)

/* ---- grid ---- */
.grid {
  box-sizing: border-box;
}

/* clearfix */
.grid:after {
  content: '';
  display: block;
  clear: both;
}

/* ---- grid-item ---- */
.grid-item {
  width: 20%;
  padding: 10px;  
  margin: 10px auto;
  float: left;
  background: #e4e4e4;
  border-radius: 5px;
}

You may be interested in Isotope Widget because implements Masonry and other layouts and funcionalities at once. https://github.com/nerburish/yii2-isotope-view, (*15)

There is also a MatchHeight.js implementation of ListView widget: https://github.com/nerburish/yii2-match-height-view, (*16)

The Versions

29/08 2017

dev-master

9999999-dev

ListView widget improved to use Masonry (http://masonry.desandro.com/)

  Sources   Download

MIT

The Requires

 

by Avatar nerburish

extension yii2 widget view dataprovider listview masonry

29/08 2017

dev-add-license-1

dev-add-license-1

ListView widget improved to use Masonry (http://masonry.desandro.com/)

  Sources   Download

MIT

The Requires

 

by Avatar nerburish

extension yii2 widget view dataprovider listview masonry

18/02 2017

1.0.0

1.0.0.0

ListView widget improved to use Masonry (http://masonry.desandro.com/)

  Sources   Download

MIT

The Requires

 

by Avatar nerburish

extension yii2 widget view dataprovider listview masonry