Cms: Control routing order

Created on 31 Jan 2017  路  2Comments  路  Source: craftcms/cms

Created by: Timothy Kelty ([email protected]) on 2015/04/02 12:33:05 +0000
Votes at time of UserVoice import: 1


From: https://craftcms.com/docs/routing

  1. Is it an entry/category request?
  2. Does the URI match any Dynamic Routes?

There are times I want these flipped (dynamic routes processed first).
It feels clunky to me to do routing logic in our twig templates, which is what that can force you into.

For example, consider a "Pages" structure, with templates going to _page.twig:

  • One entry needs to go to a different template, but since 4. matches first, we have to include that routing logic in our template.,
  • I would rather just have an exception for that in my routes.php file that got considered first.
  • You could argue this should be a single, but if you're relying on that structure, that could be a deal breaker: https://github.com/craftcms/cms/issues/899
enhancement

Most helpful comment

Craft 3 added the EVENT_SET_ROUTE event, which can be used to customize the route of any element.

All 2 comments

Is there any progress on this? We are facing the same issue right now, we have a dynamic route, that has the same route like an entry but we need our custom controller to handle it instead of the default Craft controller for certain reasons.

We don't want to set the slugs/urls of those entries to something else in order to keep the entry.getUrl functionality but we want to use a custom action.

Running the latest version of Craft 3 it's still the same routing process

Craft 3 added the EVENT_SET_ROUTE event, which can be used to customize the route of any element.

Was this page helpful?
0 / 5 - 0 ratings