![](/img/trans.png)
[英]Calling procedure in DbTableAuthAdapter class in zend framework2
[英]Calling another view from an action in Zend Framework2
我已經從github下載了一個示例ZF2項目,並在我的系統中對其進行了配置。 我無法理解路由系統,他們如何從一個動作調用視圖,以及如何從控制器中的aAction
函數調用其他視圖( b.phtml
)
在我的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
文件。 我想知道他們是如何路由的。 我們需要告訴函數調用特定視圖文件的地方。 某天,我想從controller
中的某些BlaBla function
調用xyz.phtml
,其中function name
和view file name
different
,我該怎么做。
如果您要輸入其他任何代碼,請詢問我。 我將在這里放置代碼,為此我感到很苦惱。 請幫我。
提前致謝!
如果您在控制器中未定義任何內容,則這是默認視圖位置
url_shortener / module / MyModuleName / view / my-module-name / view / 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
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.