HTML GET Requests

Sometimes when using HTML GET requests there are troubles. Some troubles might be fuzzy urls, such as &x=…&y=…&submit=<value>. I googled it, and came up with a possible option that I frequently use in Zend Framework today.

Basically it is a redirect I use mostly when searching. When I search I use q as the GET variable, and this will redirect the url to ‘…/list/?q=My search&submit=send’ because Zend Framework demands a name of every element, even if submit doesn’t need a name. What is most important here is to clear out stupid looking urls, and I prefer having ‘/q/My search/’ as it is more obvious.

This is what I do and I only use Zend Framework standard library.

1
2
3
4
5
$params = $this->getRequest()->getParams();
if(isset($params['submit'])){
    unset($params['submit']);
    return $this->_helper->Redirector->setGotoSimple('list', null, null, $params);
}

In my case I did only have the &submit appended, and in this tiny function I unset the parameter submit and send the request once more, returning me to the same site ‘list’ but with the url ‘…/list/q/my query/’
Wonderful, and yet another saticefied customer.

Lämna ett svar

E-postadressen publiceras inte. Obligatoriska fält är märkta *

*


Följande HTML-taggar och attribut är tillåtna: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>