使用Url视图助手链接时从URL中删除参数

时间:2023-01-14 23:58:34

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.

使用Url视图助手构建链接时,如果当前页面在url中包含参数,则Url视图助手生成的url也将包含参数。

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

例如在页面/ controller / action / param / value /中,代码如下:

<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?

是否可以清除参数助手输出的url?

1 个解决方案

#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

#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