Yii 1.1: tree-extension

TreeBehavior TreeActions TreeWidget
4 followers

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

//in model
public function behaviors()
{
    return array(
    'TreeBehavior' => array(
                'class' => 'ext.tree.behaviors.TreeBehavior',
'id'=>'id',
'parent_id'=>'parent_id',
...
            ),
    );
}

//in controller

public function actions()
{
        return array(
            'treeMoveUp'=>'ext.tree.actions.TreeMoveUpAction',
            'treeMoveDown'=>'ext.tree.actions.TreeMoveDownAction',
            'treeCreate'=>'ext.tree.actions.TreeCreateAction',
            'treeUpdate'=>'ext.tree.actions.TreeUpdateAction',
            'treeLoad'=>'ext.tree.actions.TreeLoadAction',
            'treeDelete'=>'ext.tree.actions.TreeDeleteAction',
            'treeChildren'=>'ext.tree.actions.TreeChildrenAction',
            'treeChildrenParent'=>'ext.tree.actions.TreeChildrenParentAction',
        );
}

public function actionAdmin()
{
    $this->render('admin');
}

//in admin[view]

$this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'YOur treeModel'));


//default tree schema
CREATE TABLE IF NOT EXISTS `tree` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lft` int(11) NOT NULL,
  `rgt` int(11) NOT NULL,
  `level` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `name` varchar(256) NOT NULL,
  PRIMARY KEY (`id`)
)

请下载tree.v2.zip,谢谢

Change Log

April 6, 2010

  • Initial release.

Total 9 comments

#9991 report it
poctsy at 2012/09/27 10:18am
good。

支持,感谢分享

#485 report it
qq71151461 at 2010/05/18 10:08am
新版修改了几处BUG

新版修改了几处BUG,同时增加了TreeSelectWidget,欢迎大家试用。 如果没能及时处理大家的问题,请访问 http://71151461.cn/?p=222

#492 report it
itlinkonline at 2010/05/16 08:28am
A better solution is CTreeView

http://www.yiiframework.com/doc/cookbook/70/

#553 report it
jerry2801 at 2010/04/28 05:32am
小用了一下,赞一个~qq71151461

目前提出两个问题: 1、admin管理树时,没有将节点往上级或下级移动的能力,且目前的方式,感觉不够直观 2、针对第一个问题,使用select控件,感觉也比较难以实现,我的建议是使用 jsTree(js组件)来做这个管理功能,jsTree拥有非常强大的api支持,希望可以搭配使用~

非常感谢分享你的成果~~~

#586 report it
mech7 at 2010/04/17 06:31am
English..

English comments but chinese form + error makes no sense :(

#612 report it
hiscaler at 2010/04/08 08:29am
节点移动有问题

比如以下数据  1 1.1 1.1.1 2 2.1 将2.1 移动到1.1.1就出错了。

#613 report it
银河王子 at 2010/04/08 03:19am
very Nice

[php] <?php $this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'YOur treeModel'));?>[php] example: model is User.php $this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'user'));

fix a bug: 'treeMoveDown'=>'myext.tree.actions.TreeMoveDownAction', should be 'treeMoveDown'=>'ext.tree.actions.TreeMoveDownAction',

other, if u left is blank: you should comment //'actions'=>array('index','view'), and if u cant add a new record,plz comment //array('lft, rgt, level, parent_id, name', 'required'),

#616 report it
JFReyes at 2010/04/07 02:29pm
Re: can you update your extension for english comments/errors?

If I may make a suggestion, I installed the Google Translate extension on my browser (Chrome) and use it frequently while here. It helps a lot...

#617 report it
Andrey G. at 2010/04/07 01:32pm
can you update your extension for english comments/errors?

can you update you comments (and errors also) for english? Right now it's useless for people that don't know chinese(or korean, sorry if i'm wrong). Thanks.

Leave a comment

Please to leave your comment.

Create extension
Downloads
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: qq71151461
  • Category: Database
  • Votes: +4 / -8
  • Downloaded: 2,271 times
  • Created on: Apr 6, 2010
  • Last updated: Aug 23, 2012