php - To restrict menu tab using Yii -


i want restrict menu tab if aren't loggin , therefore redirect loggin web page.

for example, if have in layout/main.php:

<div id="mainmenu">     <?php $this->widget('zii.widgets.cmenu',array(         'items'=>array(             array('label'=>'visit us', 'url'=>array('/visit/index')),             array('label'=>'employee', 'url'=>array('/employee/index')),             array('label'=>'login', 'url'=>array('/site/login'), 'visible'=>yii::app()->user->isguest), 

and want restrict menu tab employee , should write restriction?

i read in post somethings this, don't know how use it:

if(!isset($_session["user"])) {     header("location: homepage.php"); } 

please, me? thank much

it written in docs. define if menu element visible, use visible params, same login page, negation:

array('label'=>'visit us', 'url'=>array('/visit/index')), array('label'=>'employee', 'url'=>array('/employee/index'), 'visible'=>!yii::app()->user->isguest), array('label'=>'login', 'url'=>array('/site/login'), 'visible'=>yii::app()->user->isguest), 

to control access employee use access control filter


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -