Module Routes

I’ve got a weird one…

This is with ColdBox 3.1. Until recently we had a module route that worked just fine, but now it doesn’t and just gets picked up by the default route. Before I say anything else, here’s the routes we have. Its nothing special.

setEnabled(true);
setUniqueURLS(false);

setBaseURL(“http://#cgi.HTTP_HOST#”);

addModuleRoutes(pattern="/noticeboard", module=“staffboard”);

addModuleRoutes(pattern="/admin/articles", module=“articlecms”);
addModuleRoutes(pattern="/admin/ideas", module=“ideasadmin”);
addModuleRoutes(pattern="/admin/media", module=“mediamanager”);
addModuleRoutes(pattern="/admin/dynamictext", module=“dynamictext”);
addModuleRoutes(pattern="/admin/metrics", module=“metricsadmin”);
addModuleRoutes(pattern="/admin/staffnotices", module=“staffboardadmin”);

// Default fallback
addRoute(pattern=":handler/:action?/:id?"); // This should ALWAYS be last. It catches bloody everything!

The route that has stopped working is for “/admin/stafffnotices”.
Things I’ve tried:

  • Moving it to the top, middle of bottom of the list of routes doesn’t work
  • Renaming it to “/admin/wibble” doesn’t work
  • Renaming it to “/wibble/staffnotices” does work
  • Renaming it to “/adminstaffnotices” does work
  • accessing the module directly eg staffboardadmin:staffboardadmin.index does work
    The dynamictext and metrics routes were recently added, but removing them doesn’t allow the staff notices route to start working.

I’m utterly baffled as to why this would “suddenly” stop working. Any suggestions as to what to look at to see why the route is failing would be gratefully received

Regards

Stephen

The route that has stopped working is for “/admin/stafffnotices”. has to many f’s. It may just be a typo in you email but if you copied and pasted that is why it will go to default.

Can I ask something?

Are these routes in the module config or the routes.cfc?

If you are defining routes for modules, they really should be defined at the module level, as per the example forgebox in the full download of ColdBox.

Just a typo I’m afraid.

Annoyingly I currently have /adminstaffnotices as the module route. Taking out the “/” makes it work, but all the other module routes are absolutely fine. :expressionless:

Stephen

These are application level route in the Routes.cfm. (addModuleRoutes()) http://wiki.coldbox.org/wiki/Modules.cfm#SES-URL_Mappings

The modules themselves have internal routes defined (addRoute()) in their moduleconfig.cfc file.

The problem is the addModuleRoutes() for “/admin/staffnotices”

Stephen

These are application level route in the Routes.cfm. (addModuleRoutes()) http://wiki.coldbox.org/wiki/Modules.cfm#SES-URL_Mappings

The modules themselves have internal routes defined (addRoute()) in their moduleconfig.cfc file.

The problem is the addModuleRoutes() for “/admin/staffnotices”

Stephen

Wooo so I’ve found out what the problem is!! I’ve no idea how to fix it though…

So… To recap! The problem I have is /admin/staffnotices suddenly stopped working as a module route. I had no idea why this would be.

I’ve got SES URLs enabled. There are addModuleRoute() function calls inside the route.cfm file of the application and modules have their own routes inside of the ModuleConfig.cfc

After a lot of digging around looking at something completely unrelated I ended up looking at the SES.cfc and the preProcess and findRoute functions. I ended up looking at the routes that are stored by ColdBox and discovered why the /admin/staffnotices module route was failing.

I have a set of module routes added in routes.cfm that look like this :

// Frontend Modules
addModuleRoutes(pattern="/noticeboard", module=“staffboard”);

// Admin modules

addModuleRoutes(pattern=“admin/articles”, module=“articlecms”);
addModuleRoutes(pattern=“admin/ideas”, module=“ideasadmin”);
addModuleRoutes(pattern=“admin/media”, module=“mediamanager”);
addModuleRoutes(pattern=“admin/dynamictext”, module=“dynamictext”);
addModuleRoutes(pattern=“admin/metrics”, module=“metricsadmin”);
addModuleRoutes(pattern=“admin/staffnotices”, module=“staffboardadmin”);
addModuleRoutes(pattern=“admin/businesscards”, module=“businesscardsadmin”);

As ColdBox automatically loads all your modules into the routes for you we only specify module routes where we’re using different URLs to access a module.

We also have an “admin” module that provides a simple console for accessing the various admin functions. This admin module is called “admin” and is accessed via “/admin”, so we don’t add module route for it.

When findRoute scans through the array of routes looking for “admin/staffnotices/” it finds “admin/” and decided that this is the matching route.

Looking at the array of routes “admin/” is appearing in the middle of all the routes including those that were added using addModuleRoutes() and as admin/ is the start of the path for a few rerouted modules, any that appear after this cannot be reached using the SES Route assigned to it.

Is there anyway to order the routes in the route array? Or perhaps a way to make it so that the route finder keeps going until it finds the best match?

Thanks for any help!

Regards

Stephen

Right, so… I fixed this myself…

Apparently this thread and my descriptions are confusing, so I’m going to clear my head and start again with an explanation of the problem now that I know exactly what has been going on and how to fix it.

Regards

Stephen

Hi there Stephen… how did you fix it?