views:

136

answers:

2

I would like to remove a request parameter from the URL that is displayed in the browser window. I am creating links with special parameters that I want to retrieve in the controller, but aren't necessary after they have been retrieved.

I tried doing this, but it did not work:

$params = $this->_getAllParams();

if (!empty($params['active-tab'])) {
    //do something with $params['active-tab'] before removing it
    //then...
    unset($params['active-tab']);
    $this->_request->setParams($params);
}

Solution:

I guess Zend_Request does not work the way I thought. Here's the solution I came up with:

$params = $this->_getAllParams();

if (!empty($params['active-tab'])) {
    //do something with $params['active-tab'] before removing it
    unset($params['active-tab']);
    $this->_helper->redirector($params['action'], $params['controller'], $params['module'], $params);
}
+3  A: 

You can't actually change what's in the browser's address bar like that. The url only changes as they go from one page to the next. Unless I'm misunderstanding your question.

Joe Martinez
A: 

You could just redirect to the same page without the param.

Iznogood