Route is overwriting routes of same controller

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Route is overwriting routes of same controller

Sven Mäurer
Is it right that all other routes of the same controller are overwritten if I define the following?

Router::connect(
    '/catalogs/:name',
    ['controller' => 'catalog_groups', 'action' => 'view'],
    ['name' => '[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*']
);

I am using CakePHP 2.7.*

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Route is overwriting routes of same controller

John Andersen
Your route definition will direct all URL starting with /catalogs/ to be directed to your catalog_groups controller.
Thus if you also have a catalogs controller, then no URL will reach that controller.

Note that the URL you are redirecting to the catalog_groups controller, does not need to start with a real controllers' name. You could use other words instead of catalogs.

Did the above help you solve your issue?
Enjoy, John


On Monday, 28 December 2015 11:31:33 UTC+2, Sven Mäurer wrote:
Is it right that all other routes of the same controller are overwritten if I define the following?

Router::connect(
    '/catalogs/:name',
    ['controller' => 'catalog_groups', 'action' => 'view'],
    ['name' => '[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*']
);

I am using CakePHP 2.7.*

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.