PHPackages                             alex290/yii2-widget-content - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. alex290/yii2-widget-content

ActiveYii2-extension

alex290/yii2-widget-content
===========================

Widget content

2.0.3(1y ago)1177↓100%1MITJavaScript

Since Nov 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alex290/yii2-widget-content)[ Packagist](https://packagist.org/packages/alex290/yii2-widget-content)[ RSS](/packages/alex290-yii2-widget-content/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (25)Used By (0)

Widget content
==============

[](#widget-content)

Widget content

Installation
------------

[](#installation)

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-content "*"

```

or add

```
"alex290/yii2-widget-content": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

Подключить внешне Ckeditor 5 classic

```

```

Или скачать сборку и подключить по инструкции из документации Ckeditor

в конфиге web.php прописать

```
'modules' => [
    'widget-content' => [
        'class' => 'alex290\widgetContent\Module',
        'path' => 'upload', //path to files
    ],
],

```

run migrate

php yii migrate/up --migrationPath=@vendor/alex290/yii2-widget-content/migrations

attach behaviour to your model (be sure that your model has "id" property)

```
public function behaviors()
{
    return [
        'widget' => [
            'class' => 'alex290\widgetContent\behaviors\Behave',
        ]
    ];
}

```

Вывести виджет в админке

```
$widget = [
    'text' => [
        'name' => 'Текст',
        'preview' => '/web/images/widget/header.png',
        'fields' => [
            'name' => ['string', 'max' => 255],
            'text' => ['string'],
            'image' => ['image'],
        ]
    ],
	...
    'galery' => [ // Ключ уникальный поля
        'name' => 'Галерея', // Название виджета
        'preview' => '/web/images/widget/textImageTwo.png', // Путь к превьюшке
        'fields' => [
            'name' => ['string', 'max' => 255],  // Тип поля
            'text' => ['string'], // Тип поля
        ],
        'item' => [ // Дополнительные поля (Например в галлереи несколько картинок)
            'name' => ['string', 'max' => 255],
            'image' => ['image'],
        ]
    ],
];

```

---

Типы полей:

\['string', 'max' =&gt; 255\] - Текстовое поле

\['string'\] - Текстовая область

\['integer'\] - Целое число

\['image'\] - Изображение

\['file'\] - Файл

\['select'\] - Список

```
...
'category' => ['select', [
    '44' => 'News',
    '55' => 'Information',
]],

```

---

```

```

Получить массив объектов виджетов данной модели

```
$model->getContent();

```

Удалить виджеты

```
$model->removeWidgetAll();

$model->removeWidget($id);

```

Выводить записи на странице

```
