-- Martin Carpentier <[EMAIL PROTECTED]> wrote
(on Wednesday, 26 September 2007, 06:53 PM +0200):
> I've been following closely the progress of both ZL and ZVE  and I'm
> very happy to see that they will be both integretad in the Zend
> Framework.
> 
> What is still not clear to me though is how they relate to each other.
> 
> Are they each a different solution to the same problem (templating and
> layouts) ?  If this is the case, could you give exemples of use case
> where one would be preferable to the other ?
> 
> or
> 
> Are they providing complementary functionnality to a (global) solution
> for layouts and templates ?  If so, how would they work together in an
> application ?

They provide separate functionality, both related to views, that can
create powerful complementary functionality. 

ZVE provides some additional view helpers that allow you to do new
things:

 * Partials -- allow you to render 'subtemplates' in their own variable
   scope. The only available view variables will be those passed in to
   the helper.

 * Controller -- (this may be renamed to 'component'.) Dispatches to a
   controller action and returns the rendered content from that action.

 * Placeholders -- allow you to set variables in containers to be used
   later. Variables may be either scalars or collections, and you can
   specify pre/post content to use when you eventually retrieve them.
   Additionally, these will support capturing content to store for later
   retrieval.

 * Finally, there will be a handful of Placeholder implementations for
   common tasks -- headTitle(), headLink(), etc.

These new helpers allow you to build fairly complex views for your
application.

Zend_Layout provides support for layouts, which are really simply view
decorators. Your application will typically just spit out its own
content -- a form, a list of items, etc; Zend_Layout then decorates this
content -- usually with a view script that represents the site skeleton.
It's in this decorator view that you would put your
<html><head>...</head><body>...</body></html> structure. This is done in
an automated fashion with a large degree of flexibility, and makes use
of the response object named segments to store and retrieve content for
the layout view script.

Hopefully, you can now see why the two in combination are so powerful:
you can have your application view scripts doing things such as setting
placeholders for javascript, css, page title, etc, and then the layout
view script would pull and render these.


> On 9/20/07, Pádraic Brady < [EMAIL PROTECTED]> wrote:
> 
>     Hi Ralf,
> 
>     >The MVC component determines (somehow), based on the route, which view
>     >script is supposed to be rendered. This view script will have such a
>     >structure which renders a valid HTML document:
> 
>     The MVC component utilises an optional (enabled by default) plugin called
>     Zend_Controller_Action_Helper_ViewRenderer which insitutes a convention of
>     mapping Module/Controller/Action names to a relevent view script name. So
>     IndexController::saveAction() will automatically render the view script at
>     {viewBasePath}/index/save.phtml.
> 
>     You can modify the convention by altering a few settings on the
>     ViewRenderer (covered at least once in the past day on the mailing lists
>     ;)). Or even disable the automated rendering if you prefer.
> 
>     >I'd like to have it vice versa, where the layout is a full HTML document
>     >which renders the related view script. So I managed my application to
>     >work with this "layout" view script:
> 
>     Indeed, there have been proposals for achieving this hanging around from
>     months addressing the concept of common "Layouts". This was captured in 
> two
>     proposals - Zend_View Enhanced and Zend_Layout. The Zend_Layout 
> methodology
>     has been decided to be used in ZF 1.1 so I can point you to the
>     soon-to-be-official approach offered by Ralph Schindler.
> 
>     Unfortunately the ZF Wiki cannot be referred to since it is perfectly
>     useless to anyone in GMT and is presently offline as usual. But there's a
>     good blog post containing all the details and a brief tutorial of usage:
>     http://www.spotsec.com/blogs/archive/
>     the-basics-of-zend_layout-ahem-xend_layout.html
> 
>     In combination with Zend_Layout, pretty much all of the remaining 
> Zend_View
>     Enhanced (excepting its Layout solution) is also to be implemented in ZF
>     1.1. This adds concepts such as Partials, Components (controller calls),
>     Placeholders (capture data from view scripts for inclusion in a Layout/
>     Other View), and some other stuff.
> 
>     In combination, both ZL and ZVE should be sufficient to resolve most of 
> the
>     problems people currently have with Zend_View.
> 
>     Regards,
>     Paddy
> 
>      
>     Pádraic Brady
> 
>     http://blog.astrumfutura.com
>     http://www.patternsforphp.com
>     OpenID Europe Foundation Member-Subscriber
> 
> 
>     ----- Original Message ----
>     From: Ralf Kramer <[EMAIL PROTECTED]>
>     To: [email protected]
>     Sent: Thursday, September 20, 2007 12:30:46 AM
>     Subject: [fw-general] Using a complete HTML Template
> 
>     Hi,
> 
>     as I understood the common process of template rendering it works in
>     this manner:
> 
>     The MVC component determines (somehow), based on the route, which view
>     script is supposed to be rendered. This view script will have such a
>     structure which renders a valid HTML document:
> 
>     <?php echo $this->render('layouts/__header.phtml'); ?>
>     <p>some stuff <?= $this->fromView ?> </p>
>     <?php echo $this->render('layouts/__footer.phtml'); ?>
> 
> 
>     I'd like to have it vice versa, where the layout is a full HTML document
>     which renders the related view script. So I managed my application to
>     work with this "layout" view script:
> 
>     <html>
>     <head></head>
>     <body>
>     <h1>header stuff</h1>
>     <?= $this->render( $this->viewScript ) ?></td>
>     <h1>footer stuff</h1>    
>     </body>
>     </html>
> 
>     In my controller I do this on postDispatch()
>     public function postDispatch()
>     {
>     $this->view->viewScript = $this->getRequest()->getControllerName()
>                             . "/" . $this->getRequest()->getActionName()
>                             . ".phtml";
>     $this->_helper->viewRenderer->renderScript("layouts/main.phtml" );
>     }
> 
> 
>     It works, but it is not flexible cause _forward() renders the layout
>     view script a second time. Invocation on preDispatch() or smth. else
>     dont works, cause there are no assigned data available in the view
>     scripts. Now I believe my approach is a dead-end street...any help is
>     appreciated ;-)
> 
>     Best regards
>     /Ralf
> 
> 
> 
> 
>     
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
>     Looking for a deal? Find great prices on flights and hotels with Yahoo!
>     FareChase.
> 
> 
> 
> 
> --
> Martin Carpentier

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to