Iam using CJUI tabs for my tab display. I would like to implement a condition based display of tabs based on the user logged in. I have 2 user admin and customer. If customer is logged in I need to hide a tab. Since customer has no permission to acess those data.Iam creating tabs using this method :-
$usertype = Yii::app()->user->getstate('usertype'); // to get the user type
if ($usertype == 'customer') {
// hide $tab4
} else {
// show $tab4
}
$this->widget('zii.widgets.jui.CTab', array(
'tabs' => array(
'Summary' => $this->renderPartial('summary', null, true),
'Portfolio' => $this->renderPartial('portfolio', null, true),
'Contact' => $this->renderPartial('contact', null, true),
$tab4 => $this->renderPartial('team', null, true),
),
How can I show/hide tab4 based on the condition ?
Only add the tabs that you want to display in the array
$usertype = Yii::app()->user->getstate('usertype'); // to get the user type
$tabList = array(); // Tab list to show
$tabList['Summary'] = $this->renderPartial('summary', null, true);
$tabList['Portfolio'] = $this->renderPartial('portfolio', null, true);
$tabList['Contact'] = $this->renderPartial('contact', null, true);
$tabList['Summary'] = $this->renderPartial('summary', null, true);
if ($usertype == 'admin') { // Only 'admin' show tab 'team'
$tabList['team'] = $this->renderPartial('team', null, true);
}
$this->widget('zii.widgets.jui.CTab', array(
'tabs' => $tabList,
),