1

在下面的代码中,您会看到路由标签new和路由product/new标签popularproduct/index我无法弄清楚这些标签的用途,即使我删除它们,我也看不出 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),
    ),
));
4

2 回答 2

3

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

于 2011-12-28T04:46:05.607 回答
1

坚持住,布巴。我不会删除这些引用。如果代码作为一个整体运行,那么某处就有一个新对象!!

于 2011-12-28T04:48:01.437 回答