2016-11-25 143 views
0

我正在使用帶Applcation和User模塊的ZF3。 Application模塊是默認加載的模塊,它包含我的索引頁作爲歡迎頁面,沒有登錄信息。用戶模塊具有登錄頁面和所有用戶身份驗證內容。ZF3重定向到另一個模塊中的另一個控制器acton

我需要在我的應用程序modula index action頁面中放置一個按鈕,以重定向到用戶模塊索引頁面的登錄頁面。

我試圖使用this post的答案,但它沒有看到工作。

<p> 
<a class="btn btn-default" href=" 
    <?= $this->getHelper(redirector)->gotoSimple('index', 'index', 'user'); ?>"> 
    Other module index action 
</a> 
</p> 

這是導致以下錯誤:

的Zend \的ServiceManager \異常\ ServiceNotFoundException的

文件:

/path/to/project/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php 133 

消息:

A plugin by the name "getHelper" was not found in the plugin manager Zend\View\HelperPluginManager 

我該如何重定向到使用ZF3的另一個模塊的動作?

回答

2

您鏈接的帖子是zendframework 1.自那時以來,對ZF3進行了很多更改。

此外,重定向是您在控制器內執行的操作。例如如果某些內容已成功保存到數據庫中,則可以在同一請求中將其重定向到另一個帶有消息的頁面或查看保存的更改。

你在找什麼是url helper。你可以在zend-view模板中使用它來生成一個url。

<a href="<?= $this->url('news', ['action' => 'details', 'id' =>42]); ?>"> 
    Details of News #42 
</a> 
+0

對我清楚。謝謝。 – Mendes

相關問題