假设我有以下代码。
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");
}
}
是否有可能实现像最后一个控制器中的输出?我正在使用 zend 框架 1.11,还有其他解决方案可以实现此功能吗?
在modules/module1/views/scripts/index/index.phtml,我有
$module1NavArray = array(
array( 'label' => 'Nav1', 'uri' => '/home/module1/nav1' )
);
$container = new Zend_Navigation($module1NavContainer);
print $this->navigation( $container );
在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 );
默认模块的索引操作的输出是 Nav2 链接打印 2 次。但是,如果打印一个字符串而不是导航,那么输出就像“Nav2”和“Nav1”顺序一样。