【问题标题】:What is the tag used for in Yii framework CMenu?Yii 框架 CMenu 中使用的标签是什么?
【发布时间】:2011-12-28 04:42:16
【问题描述】:

在以下代码中,您会看到product/new 路由的标签newproduct/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),
    ),
));

【问题讨论】:

    标签: php url yii cmenu


    【解决方案1】:

    array('product/new', 'tag'=>'new')会创建一个类似index.php?r=product/new&tag=new的url,也就是说在ProductController的actionNew中,$_GET['tag'] = 'new';

    【讨论】:

    • 非常感谢。我从没想过它会被用于查询字符串。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2013-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多