OK great! That helps me a lot!
First I was surprised as I know that requestAction is kind of bad, but
I didn't know about the caching and this brings it into a total
different light.
I will try this, thanks a lot!!

On 16 Sep., 11:56, Teddy Zeenny <teddyzee...@gmail.com> wrote:
> 1. *Create controller an!
d model:*
>
> The controller and model to use depend on the table the languages are stored
> in.  For example if the languages are in a table called "languages", then
> create a model named Language and a controller named LanguagesController.
>
> 2. *Create an action that returns the list of languages *
>
> In LanguagesController, create an action called getLanguages for example.
> Basically what it does is query the languages table (
> $results=$this->Language->find('all');  )
> and then it returns the result (  return $results;   )
>
> 3.*Create an element (for example call it language_list.ctp)*
>
> First retrieve the information using requestAction
> (for example: $languages=$this->requestAction('languages/getLanguages')  )
> Then create the html needed for the languages
> (for example: foreach($languages as $language){  //html here }
>
> 4.*Call the element from the default.ctp layout*
> *         *echo $this->element('language_list');
>
> Now usually I wouldn't use requestAction as it would hit my performance, but
> since the list of languages is part of the layout, I think it would be the
> safest way to go.
> In order to fix the performance costs of requestAction, I would recommend
> the use of caching (especially that these languages will probably not change
> very often)
> You can for example cache the element i.e:
>
> you can can add a parameter to the element call from default.ctp:
>
> echo $this->element('language_list',array('cache'=>array('time'=>'+1
> week','key'=>'languages')));
>
> That is how I would do it.  I'm sure there are other (and maybe better)
> solutions, but this would definitely work.
>
> On Fri, Sep 16, 2011 at 12:32 PM, heohni <
>
>
>
> heidi.anselstet...@consultingteam.de> wrote:
> > Hi,
>
> > I have a section in my web project where I have to load from the
> > database the possible languages and their infos like flag image name,
> > ID, shortcut, etc.
>
> > Within my templates I have in the default.ctp this area:
> > <div id="flags">
> > <?php echo $html->link($html->image('en.png', array('class' =>
> > 'map_icon')), array('controller' => 'lng/eng'), array('title' =>
> > 'English', 'escape' => false));?>
> > ...
> > ...
> > ...
> > </div>
>
> > This way I have it hard coded, but as said I want to have it
> > dynamically.
> > I wonder how I can do this?
>
> > Do I have to use elements for this? Where do I have to place all my
> > database queries? In which controller?
> > Within the pages_controller? And how to get the database results into
> > the element template?
>
> > Please help me out, I am kind of lost right now...
>
> > Thanks!
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to