Suppose I have the following code.
class Module1_IndexController extends Zend_Controller_Action {
public function indexAction() {
$this->view->data1 = "This is module1's index action view";
}
}
class Module2_IndexController extends Zend_Controller_Action {
public function indexAction() {
$this->view->data2 = "This is default module2's index action view";
}
}
class Default_IndexController extends Zend_Controller_Action {
public function indexAction() {
// $module1_output = Call Module1_IndexController's indexAction view output
// $module2_output = Call Module2_IndexController's indexAction view output
$this->_helper->actionStack("index", "index", "module1");
$this->_helper->actionStack("index", "index", "module2");
}
}
Is it possible to achieve the output like the one in the last controller ? I am using zend framework 1.11 and are there any other solutions to achieve this functionality ?
In modules/module1/views/scripts/index/index.phtml , I have
$module1NavArray = array(
array( 'label' => 'Nav1', 'uri' => '/home/module1/nav1' )
);
$container = new Zend_Navigation($module1NavContainer);
print $this->navigation( $container );
And in modules/module2/views/scripts/index/index.phtml
$module2NavArray = array(
array( 'label' => 'Nav2', 'uri' => '/home/module2/nav2' )
);
$container = new Zend_Navigation($module2NavContainer);
print $this->navigation( $container );
The output of the default module's index action is Nav2 link is printed 2 times. However, if the print a string instead of navigation, then the output is as desired like "Nav2" and "Nav1" sequentially.
Action View Helper will help you to accomplish this
in modules/default/views/scripts/index/index.phtml
<?php echo $this->action('index', 'index', 'module1')); ?>
<?php echo $this->action('index', 'index', 'module2'); ?>
But action view helper have several performance and debugging issues please see these links before deciding to use it
How can I speed up calls to the action() view helper?
Action View Helper in Zend - Work around?
Using Action Helpers To Implement Re-Usable Widgets
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.