我从github下载了一个示例ZF2项目,并在我的系统中进行了配置。我无法理解他们如何通过操作调用视图的路由系统,以及如何从控制器中的b.phtml
函数调用其他视图(aAction
)
在我的WWW
中
url_shortner\module\Application\src\Application\Controller\IndexController.php
是我的索引控制器
在我的IndexController.php
我的索引函数就像这样
public function indexAction()
{
}
该函数为空,并且
中有一个视图文件url_shortner\module\Application\view\application\index\index.phtml
索引函数中没有调用index.phtml
但仍然正在加载index.phtml
文件。我想知道他们如何排除这一点。我们需要告诉函数调用特定的视图文件。有一天,我想从xyz.phtml
BlaBla function
和controller
function name
view file name
中的某些different
致电{{1}},我该怎么办?那样做。
如果你想要任何其他代码,请问我。我会把代码放在这里 我真的很挣扎。请帮帮我。
提前致谢!
答案 0 :(得分:2)
如果您在控制器中没有定义任何内容,则这是默认视图位置
url_shortener /模块/ MyModuleName /视图/我的模块名/视图/ CONTROLLER_NAME / ACTION_NAME.phtml
您可以通过以下方式更改视图:
public function indexAction(){
$view = new \Zend\View\Model\ViewModel();
$view ->setTemplate('your-module/your-controller/your-view'); //without .phtml
return $view
}