Search code examples
phpyiiyii-componentsyii-events

Dynamic url in header menu bar in yii


I am new to yii. In my project I want to pass a parameter through the Cmenu bar

 array('label' => 'Category', 'url' => array('site/catagory', 'visible' => !Yii::app()->user->isGuest),

and the parameter passing is getting from a droupdown list which is also in the navigation bar code of droupdownlist is

  $site = Site::model()->findAll();  
  $data = CHtml::listData($site, 'id', 'type');  
  echo $form->dropDownList($siteid, 'selectedsiteid', $data, array('class' => "form-control"));

which comes after the menu bar. please somebody help me.
Thanks in advance...


Solution

  • I have solved it by using javascript, the menu butttons code is

    array('label' => 'Category', 'url' => '#','linkOptions'=>array('onclick'=>'getsid()'),'visible' => !Yii::app()->user->isGuest),

    and called a java script

    function getsid()
    {
    $sid=$('#Site_selectedsiteid').val();
    window.location.href = window.location.pathname.substring( 0, window.location.pathname.lastIndexOf( '/' ) + 1 ) + 'catagory?sid=' + $sid;
    }