定制 v0lume/yii2-gallery-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

v0lume/yii2-gallery-manager

Composer 安装命令:

composer require v0lume/yii2-gallery-manager

包简介

Port of 'zxbodya/yii-gallery-manager'. Extension for yii2, that allows to manage image galleries.

README 文档

README

WARNING!!! NOT READY TO USE Yii2 port of https://github.com/zxbodya/yii-gallery-manager

Gallery Manager usage instructions

Manual

  1. Checkout source code to your project, for example to ext.galleryManager.

  2. Install and configure image component(https://bitbucket.org/z_bodya/yii-image).

  3. Import gallery models to project, by adding "ext.galleryManager.models.*" to import in config/main.php

  4. Add GalleryController to application or module controllerMap.

  5. Configure and save gallery model

     :::php
     $gallery = new Gallery();
     $gallery->name = true;
     $gallery->description = true;
     $gallery->versions = array(
         'small' => array(
             'resize' => array(200, null),
         ),
         'medium' => array(
             'resize' => array(800, null),
         )
     );
     $gallery->save();
    
  6. Render widget for gallery created above:

     :::php
     $this->widget('GalleryManager', array(
         'gallery' => $gallery,
         'controllerRoute' => '/admin/gallery', //route to gallery controller
     ));
    

Using GalleryBehavior

Using gallery behavior is possible to add gallery to any model in application.

To use GalleryBehavior:

  1. Add it to your model:

     Example:
     public function behaviors()
     {
         return array(
             'galleryBehavior' => array(
                 'class' => 'GalleryBehavior',
                 'idAttribute' => 'gallery_id',
                 'versions' => array(
                     'small' => array(
                         'centeredpreview' => array(98, 98),
                     ),
                     'medium' => array(
                         'resize' => array(800, null),
                     )
                 ),
                 'name' => true,
                 'description' => true,
             )
         );
     }
    
  2. Add gallery widget to your view:

     Example:
     <h2>Product galley</h2>
     <?php
     if ($model->galleryBehavior->getGallery() === null) {
         echo '<p>Before add photos to product gallery, you need to save product</p>';
     } else {
         $this->widget('GalleryManager', array(
             'gallery' => $model->galleryBehavior->getGallery(),
         ));
     }
     ?>
    

Changing image versions for gallery associated with behavior

  1. Update your model with new versions configuration

  2. Run following code(best place for it - in migration):

     :::php
     $models = Model::model()->findAll();
     foreach($models as $model) $model->galleryBehavior->changeConfig();
    

Note: to run in migration you should define 'webroot' path alias.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-03-03