Skip to content

Elgorm/yii2-tree-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree Manager for Yii2

Виджет для управления деревом.

Внимание!

Виджет рассчитан на работу с поведениями Павла Зимакова:

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

  1. Подключите к вашей модели любое из указанных выше поведений

  2. Подключите в контроллер дополнительные 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,
        ],
    ];
}
  1. Выведите виджет в удобном месте
use \voskobovich\tree\manager\widgets\nestable\Nestable;

<?= Nestable::widget([
    'modelClass' => 'models\ModelName',
]) ?>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 44.8%
  • JavaScript 44.8%
  • CSS 10.4%