voskobovich / yii2-tree-manager
Tree Manager using jquery.nestable plugin for Yii 2
Installs: 30 424
Dependents: 1
Suggesters: 0
Security: 0
Stars: 25
Watchers: 10
Forks: 20
Open Issues: 1
Type:yii2-widget
Requires
- php: >=5.4.0
- yiisoft/yii2: ^2.0.0
- yiisoft/yii2-bootstrap: ^2.0.0
This package is not auto-updated.
Last update: 2024-11-09 20:22:51 UTC
README
Виджет для управления деревом.
Внимание!
Виджет рассчитан на работу с поведениями Павла Зимакова:
Yii2 Adjacency List Behavior
Yii2 Nested Sets Behavior
Yii2 Nested Intervals Behavior
Yii2 Materialized Path Behavior
Отличная статья на Хабре.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist voskobovich/yii2-tree-manager "~1.0"
or add
"voskobovich/yii2-tree-manager": "~1.0"
to the require section of your composer.json
file.
Usage
-
Подключите к вашей модели любое из указанных выше поведений
-
Подключите в контроллер дополнительные actions
public function actions()
{
$modelClass = 'namespace\ModelName';
return [
'moveNode' => [
'class' => 'voskobovich\tree\manager\actions\MoveNodeAction',
'modelClass' => $modelClass,
],
'deleteNode' => [
'class' => 'voskobovich\tree\manager\actions\DeleteNodeAction',
'modelClass' => $modelClass,
],
'updateNode' => [
'class' => 'voskobovich\tree\manager\actions\UpdateNodeAction',
'modelClass' => $modelClass,
],
'createNode' => [
'class' => 'voskobovich\tree\manager\actions\CreateNodeAction',
'modelClass' => $modelClass,
],
];
}
- Выведите виджет в удобном месте
use \voskobovich\tree\manager\widgets\nestable\Nestable;
<?= Nestable::widget([
'modelClass' => 'models\ModelName',
]) ?>