使用 URL 视图帮助程序链接时从 URL 中删除参数 [英] Removing parameters from URL when using Url view helper links

查看:19
本文介绍了使用 URL 视图帮助程序链接时从 URL 中删除参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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>

将输出:

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

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

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

推荐答案

我认为 helper 的第三个参数会清除默认参数,例如

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>

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

这篇关于使用 URL 视图帮助程序链接时从 URL 中删除参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆