2011-12-28 22 views
1

在以下代碼中,您看到product/new路線的標籤爲newproduct/index路線的標籤爲popular。我無法弄清楚這些標籤是用來做什麼的,即使我刪除它們,我也看不到html輸出有什麼不同。Yii框架CMenu中使用的標籤是什麼?

$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), 
    ), 
)); 

回答

3

array('product/new', 'tag'=>'new')將創建像的index.php R =產品/新&標籤=新,這意味着在ProductController的的actionNew,$ _GET [ '標籤'] = '新' 的URL?;

+0

非常感謝。我從來沒有想過它被用於查詢字符串。 – bobo 2011-12-28 04:51:53

1

堅持那裏bubba。我不會刪除這些引用。如果代碼作爲一個整體運行,那麼就有一個新的對象!

+0

好的,我明白你的觀點。謝謝。 – bobo 2011-12-28 04:52:22