[CB 5.1.1] Event hierarchy

I’m trying to organize my handlers/events into 3 levels, so that they can be accessed by the following SES urls:

[baseurl]/product1

[baseurl]/product1/reports

[baseurl]/product1/reports/report1

How should I go about doing this?

I know if it’s just 2 levels I can simply create a “product1.cfc” under handlers folder, and create a “reports” function. But I can’t go further and create a “sub-event” for “report1”.

I’ve tried to make “product1” a sub-folder under handlers, with “reports.cfc” in the folder and “report1” a function in the cfc. But then there’s no way for me to access [baseurl]/product1.

Hope this make sense :slight_smile:

Nick

Packages (subfolders basically) are the first answer to this, but you’re also wanting to hit product1 directly. In this case you just need to create routes for the SES routing you want.

https://coldbox.ortusbooks.com/the-basics/routing

This will allow you to create every conceivable URL pattern you want and map it to any handler/action.

Cool thanks!

I can’t figure this out…

Again, all three of the following urls need to be accessible:

[baseurl]/product1

[baseurl]/product1/reports

[baseurl]/product1/reports/report1

I have in the handlers folder the following content:
[handersfolder]\product1\reports.cfc
[handersfolder]\product1\index.cfc

and in the router.cfc I have:
route(“product1”).to(“product1.index”);

But I’m getting all three urls now going to product1\index.cfc. How do I tell the router to only route “[baseurl]/product1” to index.cfc?