giles Posted October 1, 2013 Share Posted October 1, 2013 Hi, I'm working through chapter 13, adding yii-booster nav bar to my Yii development. I hope its appropriate to ask this question here (apologies in advance if it is not). I have a simplified version below. I basically want to add a visibility argument to the search form. It's wrong, but i've included it to try illustrate what I'm after. Am I unable to add and if inside and array? 'items'=>array( // L/H menu array( 'class'=>'bootstrap.widgets.TbMenu', 'items'=>array( // GUESTS array('label'=>'Log In', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest), // USERS array('label'=>'Subject', 'url'=>'#', 'visible'=>!Yii::app()->user->isGuest, 'items'=>array( array('label'=>'YOUR BROWSING TODAY'), array('label'=>'My Body - Fitness - Programs', 'url'=>'#'), array('label'=>'My Body - Fitness - Motivation', 'url'=>'#'), )), // end (always visible) array('label'=>'Contact', 'url'=>array('/site/contact')), ), ), // search field if(!Yii::app()->user->isGuest) echo ''<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search" ></form>''; , ), Link to comment Share on other sites More sharing options...
Edward Posted October 1, 2013 Share Posted October 1, 2013 Try this instead: 'visible'=> (Yii::app()->user->isGuest) ? false : true, Link to comment Share on other sites More sharing options...
Edward Posted October 3, 2013 Share Posted October 3, 2013 Actually this should work fine as you have it, works for me 'visible'=>!Yii::app()->user->isGuest, or 'visible'=> (Yii::app()->user->isGuest) ? false : true, 1 Link to comment Share on other sites More sharing options...
Recommended Posts