ZF-1198: Zend_View - support layouts.

Issue Type: Improvement Created: 2007-04-04T06:30:27.000+0000 Last Updated: 2008-03-21T16:25:38.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Alan Gabriel Bem (alan.bem) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

Related issues: - ZF-2116



Zend_Vew should to support layouts (like in RoR, CakePHP etc.)

My proposal is to create Zend_View::registerParentScript($view, $contentVariableName);

$view is script file used as a layout. $contentVariableName is name of variable that will be used as a holder of rendered child scripts.

Additional methods: Zend_View::isParentViewRegistered() // boolean Zend_View::getContentVariableName(); // string etc.

If it does not fit Zend Framework View philosphy, maybe it there is a place to implement that in Zend_Controller_Action::initView()?


Posted by Alan Gabriel Bem (alan.bem) on 2007-04-04T06:51:05.000+0000

??If it does not fit Zend Framework View philosphy, maybe it there is a place to implement that in Zend_Controller_Action::initView()???

Maybe I wrote that too fast.

But this is my implementation of what I want:

<pre class="highlight">
    public function render($action = null, $name = null, $noController = false)
        if (null === $action) {
            $action = $this->getRequest()->getActionName();
        } elseif (!is_string($action)) {
            throw new Zend_Controller_Exception('Invalid action specifier for view render');

        $view   = $this->initView();
        $script = $action . '.' . $this->viewSuffix;

        if (!$noController) {
            $script = $this->getRequest()->getControllerName() . DIRECTORY_SEPARATOR . $script;
        $layout = $this->getBasePath() . 'layout' . $this->viewSuffix;
        if (file_exists($layout) {
            /* $content_for_layout is equivalent of mentioned
                in my first post $contentVariableName */
            $view->content_for_layout = $view->render($script);
            $script = $layout;

Posted by Bill Karwin (bkarwin) on 2007-04-04T12:52:43.000+0000

Assign to Matthew.

Posted by Matthew Weier O'Phinney (matthew) on 2007-11-16T15:00:55.000+0000

The Zend_Layout proposal was accepted, and an implementation exists in the incubator at this time. Please test and provide feedback on the fw-mvc list.

Zend_Layout is scheduled for release with the 1.1.0 release.

Posted by Matthew Weier O'Phinney (matthew) on 2007-12-11T08:31:41.000+0000

Zend_Layout and all related functionality merged to core in r7078.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.