Removing parameters from URL when using Url view helper links

10,404

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>

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

Share:
10,404
Admin
Author by

Admin

Updated on June 29, 2022

Comments

  • Admin
    Admin almost 2 years

    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.

    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>
    

    will output:

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

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

  • David Snabel-Caunt
    David Snabel-Caunt almost 15 years
    Are you following me Karim? :)
  • Mike
    Mike over 14 years
    what do the null and true values stand for?
  • David Snabel-Caunt
    David Snabel-Caunt over 14 years
    See framework.zend.com/apidoc/core/Zend_View/Helper/… - the third parameter is whether or not to reset route defaults with those provided, and the fourth whether to encode the url