在Yii框架CMenu中使用的标签是什么?


What is the tag used for in Yii framework CMenu?

在下面的代码中,您可以看到product/new路由有一个标记new, product/index路由有一个标记popular。我不知道这些标签是用来做什么的,即使我删除了它们,我也看不出html输出有什么不同。

$this->widget('zii.widgets.CMenu', array(
    'items'=>array(
        // Important: you need to specify url as 'controller/action',
        // not just as 'controller' even if default acion is used.
        array('label'=>'Home', 'url'=>array('site/index')),
        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        )),
        array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
    ),
));

array('product/new', 'tag'=>'new')将创建一个类似index.php的url ?r=product/new&tag=new,这意味着在ProductController的actionNew中,$_GET['tag'] = 'new';

坚持住,宝贝。我不会删除那些引用。如果代码作为一个整体运行,那么在某个地方就会有一个新对象!!