ContentBox Routes

I’m using a widget on a page and I want to make my urls look nice.

This works but it’s not groovy enough.
http://prospectpark.nations-baseball.com/tournaments/tournament-page?tournamentid=9000

What I want to do is to be able to do:
http://prospectpark.nations-baseball.com/tournaments/tournament-page/tournamentid/9000

So I thought I’ll just add a route to handle this.

addRoute(pattern=":handler/:action/tournamentid/:tournamentid-numeric");

but then I get

The event: tournaments.tournament-page is not valid registered event.

prior to this is was using the default route:
addRoute(pattern=":handler/:action?");

What am I doing wrong?

The reason your route isn’t working is because tournaments/tournament-page are not a handler and action. I think “/:pageSlug” is the route actually being matched from the contentbox-ui module.

I was thinking extra key/value pairs should be added to the request collection automatically. What do you see if you dump out rc?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Routes go in execution order, try switching them and see how you go. From memory the routes go bottom up.

If I do /tournaments/tournament-page/tournamentid/9000

without a route it’s telling me that the page doesn’t exist. I assume this is because it’s like you said looking for a slug named 9000 rather than populating the RC.

I’ve added a route in the contentbox-ui module config
pattern="/:pageSlug/:pageSlug/tournamentid/:tournamentid-numeric"

the route is matched and the tournamentid is populated in the rc but I’m still getting

The page you requested: tournaments/tournament-page/tournamentid/9000

the currently routed url is tournaments/tournament-page/tournamentid/9000/

not tournaments/tournament-page/, I’m wondering if this is causing the issue because

prc.page = pageService.findBySlug( incomingURL, showUnpublished ); in page.index is never populating the page my best guess is because it’s not matching.

Am I the first person do this?

No you are not, in a case like this the best option is to move everything over to a module, I was under the impression this is what you had done.

The module name will have its own entry point, like tournamnets and its own set of routes. It will be these routes that then determine where in the module it gets routed too.