You can use $this->set('var', $value) in all controller and that will
be visible by the layout. You can also use the beforeRender in
app_controller.php to set something before rendering all views ( i use
this to set some specific variables I need in almost all views).
In beforeRender from app_controller.php, you can also test whcih
controller you are and which action .. so easy to distinguish cases.
Hope this helps
Franck
On Jun 12, 11:28 pm, Claudia <[EMAIL PROTECTED]> wrote:
> Thanks for the answers.
>
> It looks like I need to describe my problem a little bit better.
>
> If I follow the blog tutorial, I sooner or later create a view
> index.thtml for the posts.
> The corresponding posts_controller contains a function index() in
> which I use
> $this->set('posts', $this->Post->findAll());
> to set a template variable. This template variable is then available
> in the
> template index.thtml.
>
> The view index.thtml only creates the html that comes within the body
> tag of the final
> html output, the rest of this final html file comes from the file
> default.thtml which is the
> standard layout.
>
> Now I want to change the standard layout:
> To override the standard default.thtml I created a copy in the folder
> app/views/layouts.
>
> And here is the problem:
> I would like to use something like it is done for index.thtml - I want
> to set a template
> variable that is then available in the default.thtml. An example would
> be setting the
> meta tags depending on the selected language of the user.
>
> Setting $this->layout in a controller certainly enables me to use
> another template file as
> layout, but I still do not know how to set template variables into
> this layout.
>
> Setting such a variable in a controller for a view might work, but
> unless I misunderstand
> the suggestion this would mean setting the variable in _every_
> controller as I want to have
> the template variable always.
>
> Thanks a lot for your help
>
> Claudia
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---