╃巡洋艦㊣ 2011-06-19 19:54:46 5351次浏览 1条回复 0 0 0

以下方法我写到protected/components/Controller.php中了,然后在view中可以使用 $this->treeView() 来获取数据。 当然也可以自己写一个类,然后写一个静态方法。Class::method()来获取也可以。

public function treeView()
{
    return array(
        array(
            'text'=>'信息管理',
            'expanded'=>false,     //初始化是否展开
            'children'=>array(
            array(
                'text'=>CHtml::link('关于我们',array('info/update','cid'=>'1')),
            ),
            array(
                'text'=>CHtml::link('联系我们',array('info/update','cid'=>'2')),
            ),
            array(
                'text'=>CHtml::link('汇款方式',array('info/update','cid'=>'3')),
            ),
        ),
        array(
            'text'=>'文章管理',
            'expanded'=>false,
            'children'=>array(
            array(
                'text'=>CHtml::link('新闻动态,array('post/admin','cid'=>'1')),
            ),
            array(
                'text'=>CHtml::link('公司活动',array('post/admin','cid'=>'2')),
            ),
        ),
    );
}

view中的使用方法:

<?php $this->widget('CTreeView',array('persist'=>'cookie','data'=>$this->treeView(),'animated'=>'fast','htmlOptions'=>array('id'=>'treeview')));?>
  • 回复于 2012-03-08 10:59 举报

    三级分类怎么实现呢?是在哪里在添加一个数组?

您需要登录后才可以回复。登录 | 立即注册