2010年12月31日星期五

[fw-mvc] Re: Best way to do nested layouts?

jbeall wrote:
>
> Then have "section" layouts that specify the elements specific to only
> those sections.
>

Use a view partial (via $this->render or $this->partial if you need the
partial to have it's own variable scope). You may also choose to create view
helpers (NOTE: view helpers can call partials as well).


jbeall wrote:
>
> For example, the Master Layout might have a link to a CSS file that all
> pages use, and a footer with links to "contact us" and "terms of service"
> pages.
>

Zend Layout is what you want.
http://framework.zend.com/manual/en/zend.layout.html

NOTE: a layout is simply a view script that acts like a master page -- it
wraps your inner content. It can also call partials (via $this->render or
$this->partial)


jbeall wrote:
>
> But the different sections might use additional CSS files specific to that
> section, reference additional JS libraries, and additional navigation
> options specific to that section.
>

By using the HeadScript placeholder view helper, you can add scripts to a
stack:
$this->headScript()->appendFile('/assets/js/page.js');

The following in your layout:
<?php echo $this->headScript() ?>

will allow your stack of scripts to be output to a location of your choice
(and potentially in the order of your choice). You will need to decide on
prepending vs appending the scripts or giving them a specific stack order.

See:
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headscript


Use HeadStyle for CSS:
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headstyle

-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Best-way-to-do-nested-layouts-tp3168376p3169931.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: