philippfrenzel/yii2masonry
Composer 安装命令:
composer require philippfrenzel/yii2masonry
包简介
Yii2 Masonry Integration for Yii2
README 文档
README
yii2masonry
===============
Widget for masonry.js pinterest like layout container for Yii Framework 2 Original sources for the jquery plugin: http://masonry.desandro.com/
How to install?
Get it via composer by adding the package to your composer.json:
{
"require": {
"philippfrenzel/yii2masonry": "*"
}
}
And ensure, that you have the follwing plugin installed global:
php composer.phar global require "fxp/composer-asset-plugin:~1.0"
Due to limitations of fxp/composer-asset-plugin you also need to add the following section to the "extra" section of your composer.json
"asset-repositories": [
{
"name": "bower-asset/eventemitter",
"type": "bower-vcs",
"url": "git://github.com/Wolfy87/EventEmitter.git"
}
]
You may also check the package information on packagist.
Usage
On a page with a ListView, just add:
<?php \yii2masonry\yii2masonry::begin([ 'clientOptions' => [ 'columnWidth' => 50, 'itemSelector' => '.item' ] ]); ?> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <div class="item"><h3>Test</h3><p>Und mehr Text</p></div> <?php \yii2masonry\yii2masonry::end(); ?>
CSS
Size of columns can be defined within css
.item { width: 25%; } .item.w2 { width: 50%; }
If you have a sidebar resizeble by a button you need to reload the masonry container adding these following code:
<?php $script = <<< JS $('a#menu_toggle').on('click', function() { $('.js-masonry').masonry(); }); JS; $this->registerJs($script, View::POS_READY); ?>
My button have an ID name #menu_toggle
INFINITE SCROLL Sample:
use yii\helpers\Html; use yii\widgets\ListView; use yii\web\JsExpression; use yii\widgets\Pjax; /* @var $this yii\web\View */ /* @var $searchModel app\models\PolizzenserviceSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $script = <<<SKRIPT $('#boxes').on('infinitescroll:afterRetrieve', function(){ msnryWgArbeiten.masonry('reloadItems'); mscontainerWgArbeiten.imagesLoaded(function(){ msnryWgArbeiten.masonry() }); }); $(document).on('submit', '#WgArbeitenSearchform', function(event) { $.pjax.submit(event, '#WgArbeitenPjaxContainer') }); SKRIPT; $this->registerJs($script); ?> <?php \yii2masonry\yii2masonry::begin([ 'id' => 'WgArbeiten', 'clientOptions' => [ 'columnWidth' => 20, 'itemSelector' => '.flowers' ] ]); ?> <div id="boxes"> <?php $pjax = Pjax::begin(['id'=>'WgArbeitenPjaxContainer']); ?> <?php echo $this->render('@app/views/arbeiten/_search', ['model' => $searchModel]); ?> <?= \yii\widgets\ListView::widget([ 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'flowers'], 'itemView' => '@app/views/arbeiten/iviews/_view', 'summary' => false, 'layout' => '{items}<div style="visibility:hidden;">{pager}</div>' ]); ?> <?php echo \darkcs\infinitescroll\InfiniteScrollPager::widget([ 'itemSelector' => '.flowers', 'paginationSelector' => '.pagination', 'containerSelector' => '#WgArbeitenPjaxContainer', 'pjaxContainer' => $pjax->id, 'pagination' => $dataProvider->pagination, ]); ?> <?php Pjax::end(); ?> </div> <?php \yii2masonry\yii2masonry::end(); ?>
philippfrenzel/yii2masonry 适用场景与选型建议
philippfrenzel/yii2masonry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.8k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2014 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yii2」 「masonry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 philippfrenzel/yii2masonry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 philippfrenzel/yii2masonry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 philippfrenzel/yii2masonry 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Simple asset bundle for masonry.js (http://masonry.desandro.com/)
ListView widget improved to use Masonry (http://masonry.desandro.com/)
yii2的方式引用packery
SCEditor, a lightweight WYSIWYG BBCode & HTML editor extension for Yii 2.0 Framework
Asset Bundle to include Masonry on your Yii 2 project
统计信息
- 总下载量: 16.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-11