Tuesday, April 6, 2010

Re: Default Layout and Controller

Layouts are available to all controllers. Views are linked to
controllers, but can be changed within any action using the Controller-
>render() method including running elements instead of views etc. Any
data sent to the view is also available within the layout .

However, as cricket states, if this select needs to be available on
all pages it would be best to include it as an element which can be
cached and you can pull the data from the system for this element
using requestAction.

As requestAction loads a separate controller/action request this does
carry extra overheads, hence why we talk about caching your element.
If the options in your select list are not going to change that often
you could cache them for a couple of hours or even a day and every
time that element is requested it will first check to see if there is
a recent enough version in your cache and only when there is not will
it run requestAction to fetch the latest select list options.

If you are concerned about updating your database entries and it not
being reflected in your element quick enough you can add the following
to your add/edit/delete functions that update the select list options

@unlink(CACHE.'views'.DS.'name_of_cached_element');

This will delete the existing cached file causing a new one to be
created when the next person requests a page.

HTH

Paul

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

No comments: