giles 0 Posted October 1, 2013 Report 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>''; , ), Quote Link to post Share on other sites
Edward 108 Posted October 1, 2013 Report Share Posted October 1, 2013 Try this instead: 'visible'=> (Yii::app()->user->isGuest) ? false : true, Quote Link to post Share on other sites
Edward 108 Posted October 3, 2013 Report 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.