Thanks for the advice majna.

This leads be to ask whether the array('controller'=>'menus',
'action'=>'main') can/should be a private function?  And should it
just return the unmodified response to a find('all') call?

Also, is there a way to clear the cache programmatically, so that when
the menu items are updated, the new values appear immediately?

Thanks again,

Toby

On May 9, 10:05 am, majna <[email protected]> wrote:
> try cached elements with requestAction inside.
>
> layout ot view:
>
> <?php echo $this->element('menus/main', array('cache'=>'+1 hour'));?>
>
> menu element code:
>
> <?php
>     $data = $this->requestAction(array('controller'=>'menus',
> 'action'=>'main'));
>     foreach($data as $row):
>        ....render menu items
>     endforeach;
> ?>
>
> btw. you CAN use models inside components, even inside routes.php
> It's not recommended for large applications, because debugging,
> testing, refactoring and maintenance of code can be difficult
>
> On May 8, 11:48 pm, Toby <[email protected]> wrote:
>
> > Evening all,
>
> > I am trying to build my site navigation from the content of a database
> > table.  I have read in the CakePHP manual (http://book.cakephp.org/
> > view/64/Creating-Components) that it is not recommended to access/use
> > a model in a component.
>
> > Can anyone suggest a better way of extracting the data for the pages I
> > want it to appear on on the site?  The only thing I can think of is a
> > beforeFilter() on the AppControler, but this would be called even on
> > pages I did not need the navigation to appear.
>
> > Thanks in advance,
>
> > Toby
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to