Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Router::match skip persistent parameters #665

Open
tefra opened this Issue · 4 comments

3 participants

Chris T Nate Abele Dirk Brünsicke
Chris T

It would be great if you could skip all persistent parameters all together instead of trying to set one by one as null, something like a reset flag you could pass in the options list which would pass to the router _prepareParams method, https://gist.github.com/3884585

Nate Abele
Owner

What would be the use case for this?

Chris T

Resolve conflicts between different routes with their own persistent params.

Example:
Administrator panel with it's route

        Router::connect('admin/{:library}/{:controller}/{:action}/{:id}',
            array('admin' => true, 'library' => 'core', 'controller' => 'dashboard', 'action' => 'index', 'id' => null),
            array('persist' => array('admin', 'library', 'controller')));

And you want to link to something to the front-end, let's say a page route

        Router::connect('/article/{:slug:[\w\-\%]+}',
            array('library' => 'pages', 'controller' => 'page', 'action' => 'view', 'slug' => null),
            array('persist' => array('library', 'controller')));

You would have to set the admin param to null to make it work and that's ok.

$this->url(array('library' => 'pages',  'controller' => 'page', 'action' => 'view', 'admin' => null, 'slug' => $item->slug))

But imagine having a system like a cms/cmf where you could install libraries from various sources, it's impossible to resolve all persistent parameters conflicts. Let's say you have a contact-us plugin and you want to display a link in the header of all pages, the url would have to be hard-written because you don't know what conflicts may come up. That's where the reset flag comes in handy.

$this->url(array('library' => 'contact',  'controller' => 'form', 'action' => 'view'), array('reset' => true));
Dirk Brünsicke

i'd agree - i had that use-case several times and find it tiring to set all these parameters to null

Nate Abele
Owner

Got it, thanks for the feedback, guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.