zantknight/yii2-gallery4

bootstrap4的相册管理器

安装: 399

依赖项: 1

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 0

公开问题: 1

类型:yii2-extension

v1.1.1 2023-12-07 09:35 UTC

This package is auto-updated.

Last update: 2024-09-07 11:20:10 UTC


README

bootstrap4的相册管理器

安装

安装此扩展的首选方式是通过composer

运行以下命令之一

php composer.phar require --prefer-dist zantknight/yii2-gallery4 "*"

或者

"zantknight/yii2-gallery4": "*"

将以下内容添加到你的composer.json文件的require部分。

使用方法

  1. 通过调用此命令迁移以创建相册表
    php yii migrate --migrationPath=@vendor/zantknight/yii2-gallery4/migrations
    
  2. 更新config/web.php
    return [
        ...
        'modules' => [
            'gallery4' => [
                 'class' => 'zantknight\yii\gallery\Module',
             ],
        ]
    ]
  3. 将此行为添加到你的模型中
     ...
     use zantknight\yii\gallery\Gallery4Behavior;
    
     class YourModel extends \yii\db\ActiveRecord
     {
         ...
    
         public function behaviors()
         {
             return [
                 ...
                 [
                     'class' => Gallery4Behavior::className(),
                     'model' => $this
                 ]
             ];
         }
     }
  4. 将此内容放入你的视图中
    <?= \zantknight\yii\gallery\Gallery4Widget::widget([
         'ownerModel' => $model,
         'multiple' => true
     ]); ?>
    描述
    • ownerModel 视图中使用的模型类
    • multiple 多次上传状态
  5. 将此片段放入params.php
     return [
         ...
         'bsVersion' => '4.x',
     ];
  6. 在你的"web"文件夹中创建"media"文件夹
  7. 你将得到类似这样的结果 alt text alt text alt text alt text
  8. 对于图像管理,请访问Module Gallery4 URL (/gallery4/admin),你将得到类似这样的结果 alt text