"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%" Donald Knuth<http://en.wikipedia.org/wiki/Donald_Knuth>
Simplicity (KISS principal - http://en.wikipedia.org/wiki/KISS_principle ) is the most important issue in programing. If requestAction <http://book.cakephp.org/view/434/requestAction> is the simple way to do it, use it. If you fail to the 3% try to deal with it. In your case AJAX may help. But again only if you are not satisfied with the simple solution. On Sat, Feb 20, 2010 at 6:30 AM, Dr. Loboto <[email protected]> wrote: > Your approach looks right. If you have this sidebar on all pages, and > variable name with data is same across all pages (highly recommended) > better place element call in layout and do not mix it with page > content. If sidebar content is independent from current page you can > place data retrieve for it into beforeRender AppController callback. > > On Feb 19, 3:48 pm, WebbedIT <[email protected]> wrote: > > Lol, I think Zaky really likes elements as I am seeing that short post > > of his more and more, and probably rightly so as this does seem to be > > the commonly accepted way to tackle the issue of sidebars. > > > > However, can I throw what I am doing open for discussion so my errors > > can be corrected if necessary. It uses elements, but not sure if I am > > passing in data in the commonly accepted manner. > > > > I have an element called side_content.ctp: > > <?php > > if(isset($data)): > > foreach($data AS $row): > > echo $this->element($row['element'], array('data'=>$row['data'])); > > endforeach; > > endif; > > > > I then pass that a data array with something like the following > > Array > > ( > > [0] => Array > > ( > > [element] => cause_profile_summary > > [data] => array('Cause'=>array('name'=>'Stokenchurch Dog > > Rescue', ...)) > > ) > > [1] => Array > > ( > > [element] => sub_menu_cause > > [data] => array('Cause'=>array('page_count'=>3, ...)) > > ) > > [2] => Array > > ( > > [element] => latest_friends > > [data] => array('Freind'=>array(0=>array('name'=>'Friend > > One', ...))) > > ) > > > > ) > > > > I form the array to be passed to the side_content element in my > > controller pulling data in from related models, then in the view call > > <?php if(isset($sideContent)) echo $this->element('side_content', > > array('data'=>$sideContent)); ?> > > > > Is this a sensible approach to dynamic content for side bars or should > > I dump all of this and revert to: > > > > http://book.cakephp.org/view/434/requestAction > > > > I stayed clear of requestAction() previously as there was a lot of > > discussion over performance issues, but now the book certainly seems > > to reccomend it for this purpose. > > > > Sorry to hijack the thread, but hopefully this lot should be a lot of > > use in what you're doing. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<cake-php%[email protected]>For > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > -- Regards, Zaky Katalan-Ezra QA Administrator www.IGeneriX.com Sites.IGeneriX.com 054-7762312 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
