Wednesday, October 27, 2010

Re: 2 column css layout: click on link in left column, opening the view in the right column

On Oct 28, 5:17 am, Tomfox Wiranata <tomfox.wiran...@gmail.com> wrote:
> how do view and layout work together? thx :)

Conceptually, the view should only contain the HTML relevant to a
specific action, while the layout should contain HTML that is common
across multiple actions. How this is achieved is by using the
'$content_for_layout' placeholder in your layout. Cake takes the
rendered view and places it in that spot.

Now, if you need a distinct "layout" for every action, then you might
want to consider created a really basic layout which has only the bare
minimum of HTML that is common across these actions (like the header
and footer, for example), and then let your view do the rest of the
rendering.

So in your above example, you would have a layout called "test.ctp"
that has common things and a call to echo $content_for_layout, and
then edit.ctp will take care of things specific to the edit action.

Additionally, you might want to consider defining your own Elements,
which are like components of a view. That way, you can just invoke the
same element in multiple views and by passing it some parameters you
can customise it for the current view. This would be useful if you
needed to customise your left-hand column depending on which view/
action you are in, but only in a small way (say, selecting the
"active" menu item). But ignore this if it's not relevant/too
confusing :)

HTH,

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

No comments: