php - 禅德 : The url assembled by the URL view helper is incorrect

标签 php zend-framework zend-route

I have a problem using my url view helper. I have defined custom routes like so: 
; Index
routes.domain.type = 'Zend_Controller_Router_Route_Static'
routes.domain.route = '/'
routes.domain.defaults.controller = index
routes.domain.defaults.action = index

自定义 url 一切正常,但我无法正常组装。 我尝试使用 View 中的以下代码添加链接:

$this->url(array('controller' => 'search', 'action' => 'index');

问题是,当我在索引 Controller 的索引页面中使用此代码时,返回的网址是当前 Controller /操作的网址,而不是我需要的网址。

最佳答案

这是因为 URL View 助手选择最后一个事件路由。如果您有多个路线,请始终定义您正在使用的路线:

$this->url(array('controller' => '搜索', 'action' => '索引'), '默认');

第二个参数是要使用的路由,第三个可选参数是是否需要重置所有参数(true/false)。

关于php - 禅德 : The url assembled by the URL view helper is incorrect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8184465/

相关文章:

php - PHP 中的 Fitbit API 响应处理

PHP:如何不对 Web 应用程序根目录进行硬编码

PHP 发送的电子邮件有 =0A=0A 而不是新行

php - Zend 翻译 Zend 表单!

php - 在 php 中以法语显示月份名称?

javascript - 多个文件作为电子邮件附件上传

mysql - Zend Db 按自定义列表排序

php - Zend Framework 2中的路由,跳过url中的 'index'操作但获取id

php - Zend Routing::如何将所有请求发送到 application-> IndexController 到 application->module->store->IndexController

zend-framework2 - 如何从 Zend Framework 2 中的 View 文件访问路由、发布、获取、服务器等参数