Zend url : get parameter always stay in the url

十年热恋 提交于 2019-12-02 22:09:38

问题


I have some trouble using the Zend url helper with get parameter. In a view, I have pagination which send extra parameters in get (so in the url), so that's ok. But that is not ok is that the parameters always stay in the url even if I change page. In fact, the zend url helper - I use to generate the url of link or form's action - add automaticaly the parameter at the end of the url so whatever the link I click, I have this parameters...

//In my controller
$this->_view->url(array("action"=>"action-name");
// generate for example : "mywebsite/controller-name/action-name/pays/4" but I don't want the "/pays/4"

Thank you for your help


回答1:


The url method accepts additional parameters. One of them resets the get-string parameters.

url (

array $ urlOptions = array(),
$ name = null,
$ reset = false,
$ encode = true
)
Generates an url given the name of a route.

Parameters:

array $urlOptions - Options passed to the assemble method of the Route object.
mixed $name - The name of a Route to use. If null it will use the current Route
bool $reset - Whether or not to reset the route defaults with those provided

Returns: string Url for the link href attribute.

It's all in the doc. The above is for ZF version 1.10




回答2:


The definition or url() is

public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)

So try setting the third parameter ($reset) to true



来源:https://stackoverflow.com/questions/8943502/zend-url-get-parameter-always-stay-in-the-url

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