Removing parameters from URL when using Url view helper links

僤鯓⒐⒋嵵緔 提交于 2019-11-29 09:35:33

问题


When using the Url view helper to build links, if the current page has parameters in the url, the url generated by the Url view helper will contains parameters as well.

For instance in the page /controller/action/param/value/ the following code:

<a href="<?php echo $this->url(array(
    'controller' => 'index',
    'action' => 'index'
)) ?>">Dashboard</a>

will output:

<a href="/index/index/param/value/">Dashboard</a>

Is it possible to clean the url outputted by the helper of parameters?


回答1:


I think the third parameter to the helper will clear the default params, e.g.

<a href="<?php echo $this->url(array(
    'controller' => 'index',
    'action' => 'index'
), null, true) ?>">Dashboard</a>

Documentation: http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial



来源:https://stackoverflow.com/questions/993725/removing-parameters-from-url-when-using-url-view-helper-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!