Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Overrule #modelascontrollerroutes in routes.yml


4 Posts   317 Views


8 August 2013 at 1:48am (Last edited: 8 August 2013 1:53am), Forum Moderator, 1095 Posts

Hi all

This has been bugging me for the best part of a year now, and I'm beginning to think the use of wildcards in YAML isn't as innocent as it seems.

For my LanguagePrefix module, I'm still trying to overrule/replace the modelascontrollerroutes, without success. If I'm correct, this is how the framework/cms routes are prioritized (and I placed my rule where I think it should be):

rootroutes -> Before *
modelascontrollerroutes -> Before: *, After: rootroutes
languageprefixroutes -> Before: ???, After: ???
coreroutes -> Before: *, After: rootroutes, modelascontrollerroutes
adminroutes -> Before: *, After: rootroutes, coreroutes, modelascontrollerroutes
legacycmsroutes -> After: adminroutes

Obviously I want my lanuageprefixroutes after the modelascontrollerroutes, but before the coreroutes. After is easy, but Before always triggers the conflict error, whatever I try. Below one of many tries:

Name: 'languageprefixroutes'
After: 'cms/routes#modelascontrollerroutes'
Before: 'framework/routes#coreroutes' <-- look, no wildcards

Has anyone ever succeeded in doing this? Can it actually be done?

Thanks, Martine


11 August 2013 at 6:10pm Forum Moderator, 5511 Posts

I think the Wildcard approach is not the right one. If you remove the Before: * for coreroutes, adminroutes does that solve your issue? I wonder if these should only define after segments and let modules conclude if they need to be placed after *.


12 August 2013 at 1:36am (Last edited: 12 August 2013 1:37am), Forum Moderator, 1095 Posts

Hi Will,
Thanks. I guess if I remove the Before:'*' from framework and cms routes, i won't have a problem positioning my rule after #coreroutes and before #adminroutes.

I absolutely think framework and cms routes can easily be set up without the use of wildcards, and that would definitely solve the problem for other modules.

I posted this on core dev some months ago, but unfortunately there was no response at that time :)!searchin/silverstripe-dev/Routes.yml/silverstripe-dev/njFeb3ZJ_jc

The documentation states that priority is determined based on the number of wildcards used, where Before '*' stands for three wildcards, Before:'#adminroutes' stands for two, so something like Before 'framework/routes#adminroutes' should at least have presedence, but that doesn't seem to be that simple.

Maybe I should set it up again, do all the test and submit a pull...


12 August 2013 at 7:25pm Forum Moderator, 5511 Posts

Tests sound like the best place to start!