Andrew
Andrew

Reputation: 238937

Zend Framework: How to remove a request parameter from the URL?

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);
}

Upvotes: 1

Views: 4463

Answers (2)

Iznogood
Iznogood

Reputation: 12853

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

Upvotes: 0

Joe Martinez
Joe Martinez

Reputation: 854

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.

Upvotes: 3

Related Questions