using Zend View Action Helpers & disabling layout
i am just reading on zend view action helpers on zend framework docs. so i created an index action
// index.phtml
...
echo $this->action(
$action = "widgetenabledoutput",
$controller = "index",
$module = null,
array(
"noLayout" => true,
"itemsPerPage" => 15
)
);
// index controller (IndexController.php)
public function widgetenabledoutputAction() {
$noLayout = $this->getRequest()->getParam("noLayout");
$itemsPerPage = $this->getRequest()->getParam("itemsPerPage");
if ($noLayout) { // i made this such that this page/action can be displayed with layout and without.
$this->_helper->layout->disableLayout();
}
$html = "<ul>";
for ($i = 1; $i <= $itemsPerPage; $i++) {
echo "<li>Item $i</li>";
}
$html .= "</ul>";
$this->view->html = $html;
}
the error i got was that in the index action, index.phtml, my intention was to get the output (list) of widgetenabledoutputAction
not the layout of widgete开发者_运维百科nabledoutputAction
but i want the layout of indexAction
does it make sense? am i doing something wrong? or must i make a delicated action for something i want to use a action helper from?
If you just want to use a different view use
$this->_helper->viewRenderer('index');
You don't need to call another action to use the same view
i have found out that using a zend view action helper is smart enuf and automatically disables layout for that view. so it only gives the output from that action view script and not the layout. what i did seem like disable layout for the request not what i wanted.
精彩评论