[Solar-talk] Example Solar Code
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sat Mar 17 20:27:10 PDT 2007
On 3/17/07, Michael Soule wrote:
>
> It appears that layouts are composed of the the html shared by a group of
> pages and the views contain html specific to a given page or action. Is this
> correct? Is there more to it than that?
>
I think this is correct, Michael. The "more" would be that
Solar_Controller_Page keeps two stacks for directory paths: one for layouts,
and other for views. Once a view is fetched, and a layout is required (it
wouldn't be required in Ajax requests), the fetched view is assigned to its
slot in the layout template.
The more or less tricky part is that if you want to have a "dynamic" view
templates in a layout, you can't just include the template using a variable,
because inside layouts the path stack in use is the layout one, so the
template won't be found because it is in the view directory. There are
workarounds for these, like including the /View directory as a fall back for
the layout stack, or just not including view templates in a layout -
instead, use a variable and assign to it a fetched view template.
There are some tricks to make layouts and views more reusable or, better,
easier to manage, but it will depend on you to try and find the best
approach that works for you. After a while, the best approach for me was
this: my layouts never have specific app logic or content; they are just
empty skeletons filled by the controller with view templates. I prefer to
keep the layout agnostic and put all specific app stuff in the view
directory, because it becomes more straightforward to mix dynamic parts or
manipulate them using helpers. Also, then you just need one or two good
skeletons to rule them all. :)
rodrigo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20070318/28cf5d6b/attachment.htm
More information about the solar-talk
mailing list