2017 © Pedro Peláez
 

yii2-extension yii2-match-height-view

ListView widget improved to use Jquery Match Height (https://github.com/liabru/jquery-match-height)

image

nerburish/yii2-match-height-view

ListView widget improved to use Jquery Match Height (https://github.com/liabru/jquery-match-height)

  • Tuesday, June 26, 2018
  • by nerburish
  • Repository
  • 1 Watchers
  • 5 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 15 % Grown

The README.md

Yii2 MatchHeight ListView Widget

http://nerburish.com/yii2-matchheight-listview-widget/ en 🇪🇸, (*1)

ListView widget improved to use Jquery MatchHeight.js (http://brm.io/jquery-match-height/), (*2)

Demo Screenshot: macth-height-view-demo, (*3)

Installation

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

Either run, (*5)

php composer.phar require --prefer-dist nerburish/yii2-match-height-view "dev-master"

or add, (*6)

"nerburish/yii2-match-height-view": "dev-master"

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

Usage

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

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

In clientOptions you can pass the MatchHeight.js options to modify the plugin behavior (see https://github.com/liabru/jquery-match-height#options), (*10)

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

Exemple:, (*12)

We have this model:, (*13)

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

    public $title;

    public $description;
}

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

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

Then in our view, we run the widget:, (*15)

<?php echo \nerburish\matchheight\MatchHeightView::widget([
    'dataProvider' => $dataProvider,
    'itemView' => '_item',
    'cssFile' => [
        "@web/css/grid-demo.css"        
    ]
]) ?>

The css used for the demo:, (*16)

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

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

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

You may also be interested in Masonry.js ListView widget: https://github.com/nerburish/yii2-masonry-view, (*17)

The Versions

26/06 2018

dev-master

9999999-dev

ListView widget improved to use Jquery Match Height (https://github.com/liabru/jquery-match-height)

  Sources   Download

MIT

The Requires

 

by Avatar nerburish

extension yii2 widget view dataprovider listview masonry macth-height