On 8/3/06, lorenzo wrote:
>
> Mark Quinn ha scritto:
>
> My current problem is how to get a view to set a variable that is
> available in the layout. From everything i've read. this should be
> easy, but i'm just not getting any loving.
>
> I baked a trivial example:
>
> my layout contains
> <p>my favourite cheese is <?= $cheese ?></p>
>
> > my view contains
> > <?
> > $this->controller->set( 'cheese', 'cheddar' );
> > $cheese = 'brie';
> > ?>
> put this in your controller:
> $this->set('cheese','padano');
>
I understand that variables are _usually_ set in the controller. As an
experienced RoR developer, I am used to being able to have a VIEW set
a variable that is used by the LAYOUT. This makes complete sense to
seperate code logic and presentation. A trivial example is that the
controller programmer doesn't care what the title of a page is - that
is the call of the page designer/html person (yes, localisation etc,
may change this - but this is just a simple example).
A better example may be when the designer/html person wants the layout
to include a different element for certain pages/views. Why have two
layouts, solely in order to replace one element with a different one?
Wouldn't it be nice if the view could dictate which element it needed?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---