arogachev/yii2-tree
最新稳定版本:0.1.0
Composer 安装命令:
composer require arogachev/yii2-tree
包简介
Database tree structures management for Yii 2 framework
README 文档
README
Database tree structures management for Yii 2 framework
Currently it's Nested Sets management extension based on:
Contents:
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist arogachev/yii2-tree
or add
"arogachev/yii2-tree": "*"
to the require section of your composer.json file.
Features
- Basic actions with tree nodes: creating, renaming, moving, deleting
- Saving state of nodes (opened / closed)
- Links for updating node
Usage
Add this to application config:
'controllerMap' => [ 'tree' => 'arogachev\tree\controllers\TreeController', ],
Attach additional behavior along with NestedSetsBehavior to your model:
use arogachev\tree\behaviors\NestedSetsManagementBehavior;
/** * @inheritdoc */ public function behaviors() { return [ NestedSetsBehavior::className(), NestedSetsManagementBehavior::className(), ]; }
The last step is display widget:
use arogachev\tree\widgets\NestedSets; use frontend\modules\department\models\Department;
<?= NestedSets::widget([ 'modelClass' => Department::className(), ]) ?>
Behavior configuration
nameAttribute - string, the name of attribute storing the name of node. Defaults to name.
saveState - boolean, save state of nodes (opened / closed). Defaults to false.
isOpenedAttribute - string, the name of attribute storing if the node opened or closed.
Used together with saveState. Defaults to is_opened.
Widget configuration
modelClass - string, the full model class including namespace of managed model. Required.
updateUrl - string, url for updating model in separate page.
Will be processed by yii\helpers\Url::to().
jsTreeOptions - array, options for JsTree widget. Example:
'jsTreeOptions' => [ 'clientOptions' => [ 'core' => [ 'strings' => [ 'New node' => 'Новый отдел', ], ], ], ],
统计信息
- 总下载量: 1.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-05-04