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.

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

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

SilverStripe 3.0.2-rc2 Update - Routes


Reply


2 Posts   926 Views

Avatar
xini

Community Member, 8 Posts

13 September 2012 at 11:10am

Edited: 13/09/2012 11:11am

I have just upgraded my project to 3.0.2-rc2 and i am running into problems with the definition of a custom route.

I would like to insert a route before the modelascontrollerroutes but it always gives me either a 404 or the following error, whatever I try:

Fatal error: Based on their before & after rules two fragments both need to be before/after each other in {path}\framework\core\manifest\ConfigManifest.php on line 293

I followed the description on [url]http://doc.silverstripe.org/framework/en/3.0/reference/director[/url] (with modifications for the changes in 3.0.2-rc2), but that doesn't work. here my code of the routes.yml file:

---
Name: shareroutes
After: '#coreroutes'
---
Director:
rules:
'': 'RootURLController'
'$URLSegment//$Action/$ID/$OtherID': 'ShortlinkController'

How do I insert a custom route that should be triggered after #coreroutes and before #modelascontrollerroutes?

Thanks.

Avatar
hfried

Administrator, 7 Posts

21 September 2012 at 11:05am

After discussing with Xini on IRC, the solution is this:

share/_config/routes.yml

---
Name: modelascontrollerroutes
After: cms/routes#modelascontrollerroutes
---
Director: .....
---

This issue is that, in order for every module to not explicitly have to state "After: framework, cms", the framework and cms modules have a "Before: *" statement. This makes it impossible to insert config fragments in-between fragments from cms and framework.

The work around we're using here is that framework/_config/routes.yml purposely lists only the fragment identifier in the before & after rules, not the module name. This means that by providing another fragment with the same identifier but in a different module we can insert that fragment in the same place as the original.