For example, I have a page in my application called page2 that I want to access like mysite.com/page2
in the application.ini file I would have a section for it
resources.router.routes.index.route = '/page2/'
resources.router.routes.index.defaults.controller = index
resources.router.routes.index.defaults.action = page2
My question is, what if I have several pages that I want to access as children of the index controller. There must be a method that doesn’t involve creating a new section in application.ini every time I have a new page…
Any advice?
This StaticRoute plugin by Ekerete Akpan uses reflection to inspect your default controller and add static routes of the form
/actionnamefor all action methods it finds there.This means that you don’t have to add an explicit route for each of those actions. Just add an action to the default controller and the corresponding view-script in the expected place. No need to change any routing files or
application.inijust to add a new top-level url.Note, however, that since the plugin uses Reflection to inspect your default controller, using it has performance implications.