Download the PHP package alex290/yii2-widget-gallery without Composer
On this page you can find all versions of the php package alex290/yii2-widget-gallery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-widget-gallery
Widget gallery
Yii2 Widget gallery
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by :
в конфиге web.php прописать
'modules' => [
'widget-gallery' => [
'class' => 'alex290\widgetgallery\Module',
'path' => 'upload', //path to files
],
],
run migrate
php yii migrate/up --migrationPath=@vendor/alex290/yii2-widget-gallery/migrations
attach behaviour to your model (be sure that your model has "id" property)
public function behaviors()
{
return [
'gallery' => [
'class' => 'alex290\widgetgallery\behaviors\Behave',
]
];
}
Вывести виджет в админке
<?= $model->getGalleryAdmin($title = 'Название', $desc = 'Описание') ?>
$title = false
Скрывает поле $title
$desc = false
Скрывает поле $desc
Добавить к модели новые изображения
$model->attachGellery([
'../../image.png',
'../../image1.png',
//...
]);
Изменить данные в объекте галереи
$model->updateGalleryItem($id, $title = 'Заголовок', $desc = 'Описание');
$title и $desc - Необязательны
Получить массив объектов виджетов данной модели
$model->getGallery();
В контролле для загрузки или изменения данных
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->getNewImages()->upload($model);
...
}
Удалить виджеты
$model->removeGalleryAll();
$model->removeGalleryItem($id);
Выводить записи на странице