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/