Here’s my problem, by default, this is what my homepage menu looks like (works)
when I click the login, and logged in a ‘User’, it becomes like this (works)
when log out, it comes back to the first screen shot.
Now, when I click the ‘Companies’ link, here’s what one will see,
then click a company, the visitor get’s redirected to a ‘Staff Login Page’,
after the staff logged in, my menu now looks like this,
how will I remove the ‘My Companies’ link at the menu ‘if and only if’ the logged in user is a staff ?
here’s my code at the main.php layout file
<div id="header">
<div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
</div><!-- header -->
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about'),'visible'=>Yii::app()->user->isGuest),
array('label'=>'Contact', 'url'=>array('/site/contact'),'visible'=>Yii::app()->user->isGuest),
array('label'=>'My Companies', 'url'=>array('/wsmembersdetails/index'),'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Companies', 'url'=>array('/companies/index'),'visible'=>Yii::app()->user->isGuest),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
</div><!-- mainmenu -->
if am gonna do it like this ,
array('label'=>'My Companies', 'url'=>array('/wsmembersdetails/index'),'visible'=>!Yii::app()->user->isGuest),'visible'=>!Yii::app()->staffUser->isGuest,
am getting an error
Object configuration must be an array containing a "class" element.
I had my user components set to this
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=>array('companies/login'),
),
'staffUser'=>array(
'allowAutoLogin'=>true,
'stateKeyPrefix'=>'staff_',
),
what should I do ?