Prev | Current Page 91 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

For SiteTemplate, we use this hook to render the master layout with the content from the action views
embedded with it. This is shown in Listing 3.4.
Listing 3.4: SiteTemplate::dispatchLoopShutdown()
public function dispatchLoopShutdown()
{
if (!$this->_renderLayout) { #1
$frontController = Zend_Controller_Front::getInstance();
$request = $frontController->getRequest();
$response = $frontController->getResponse();
$body = $response->getBody(); |#2
$this->_view->actionContent = $body; |
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
$layoutScript = $this->getLayoutScript(); #3
$content = $this->_view->render($layoutScript),'default'; |#4
$response->setBody($content); |
}
}
(annotation) <#1 Flag to turn off rendering of master>
(annotation) <#2 The rendered action content >
(annotation) <#3 Name of master template can be overridden>
(annotation) <#4 Render master template>
dispatchLoopShutdown() does quite a lot for so few lines. Firstly we check that the user actually wants to
render the master layout template (#1). There are multiple reasons why she might not, such as using Ajax or
sending non html data such as a CSV file.


Pages:
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
pustaki szklane House Extension Kąty Rybackie noclegi kasyno Kołobrzeg