Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alex290/yii2-widget-gallery
https://github.com/alex290/yii2-widget-gallery
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/alex290/yii2-widget-gallery
- Owner: alex290
- Created: 2020-12-09T11:41:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-14T11:42:47.000Z (about 4 years ago)
- Last Synced: 2024-10-21T03:03:30.159Z (3 months ago)
- Language: JavaScript
- Size: 503 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Widget gallery
==============
Yii2 Widget galleryInstallation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist alex290/yii2-widget-gallery "*"
```or add
```
"alex290/yii2-widget-gallery": "*"
```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);
Выводить записи на странице
getGallery() != null) : ?>
getGallery() as $key => $gallery) : ?>