Zend Framework

Zend_View - support layouts.

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9.1
  • Fix Version/s: 1.5.0
  • Component/s: Zend_View
  • Labels:
    None
  • Fix Version Priority:
    Must Have

Description

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()?

Issue Links

Activity

Hide
Alan Gabriel Bem added a comment -

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:

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;
        };
        $this->getResponse()->appendBody(
            $view->render($script),
            $name
        );
    }
Show
Alan Gabriel Bem added a comment - 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:
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;
        };
        $this->getResponse()->appendBody(
            $view->render($script),
            $name
        );
    }
Hide
Bill Karwin added a comment -

Assign to Matthew.

Show
Bill Karwin added a comment - Assign to Matthew.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

Zend_Layout and all related functionality merged to core in r7078.

Show
Matthew Weier O'Phinney added a comment - Zend_Layout and all related functionality merged to core in r7078.

People

Vote (2)
Watch (4)

Dates

  • Due:
    Created:
    Updated:
    Resolved: