Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

giles's Achievements


Newbie (1/14)



  1. 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>''; , ),
  2. Yes, that was the first bit putting me off, was the fact that I hadn't seen anything like that in eamples or tutorials so didn't know if I was flying against convention. thanks in advance
  3. Hi all. So I'm a Yii learner. Just completed YiiBook which I really enjoyed. I'm now trying to put its principles into practise, however i'm still not fully getting the "mindset" so I need to turn to the experts for help. Goes like this // assign $id=$model->id; // get topic $topic = Yii::app()->db->createCommand() ->select('id, parent_id, name, description, url') ->from('silo') ->where('silo.id = '.$id.'') ->queryAll(); ?> <img class="title" src="<?php echo $topic[0]['url']; ?>" width="300" height="200" /> <div id="headline"><strong><?php echo $topic[0]['name']?></strong><em> Magazine</em></div> <?php // SUB TOPICS $subtopics = Yii::app()->db->createCommand() ->select('id, parent_id, name, description') ->from('silo') ->where('silo.parent_id = '.$id.'') ->queryAll(); // read out for ($x = 0 ; $x < count($subtopics) ; $x++) { // query $entries = Yii::app()->db->createCommand() ->select('*') ->from('entrysilo') ->Join('entry', 'entrysilo.entry_id = entry.id') ->where('entrysilo.silo_id = '.$subtopics[$x]['id'].'') ->queryAll(); // title print "<fieldset>"; print "<h3>" . $subtopics[$x]['name'] . "</h3>"; print '<div id="h3description">' . $subtopics[$x]['description'] . '</div>'; // read entries out for ($y = 0 ; $y < count($entries) ; $y++) { print '<a href="http://domain/index.php?r=entry/view&id='.$entries[$y]['id'].'">' . $entries[$y]['title'] . '</a>'; print '<br/>'; print '<div id="description">' . $entries[$y]['entry_description'] . '</div>'; } print "</fieldset>"; } I have a report that runs a number of individual and nested MySQL queries before producing a newspaper type report. In my ignorance I first built this into a view utilising Query Builder. This works OK, but as Larry points out on page 20, this should really go into the model. trouble is that I can't find any examples of how I should go about building a nested query in the model, then reading it out to a layout. I'd really appreciate your advise thanks in advance
  • Create New...