Named Routes
You can register routes in ColdBox with a human friendly name so you can reference them later for link generation and more.
Registering Named Routes
You will do this in two forms:
Using the
route()
method and thename
argumentUsing the
as()
method
Generating URLs to Named Routes
You will generate URLs to named routes by leveraging the route()
method in the request context object (event).
Let's say you register the following named routes:
Then we can create routing URLs to them easily with the event.route()
method:
Inspecting The Current Route
The request context object (event) also has some handy methods to tell you the name or even the current route that was selected for execution:
getCurrentRouteName()
- Gives you the name of the current route, if anygetCurrentRoute()
- Gives you the currently executed routegetCurrentRoutedURL()
- Gives you the complete routed URL pattern that matched the routegetCurrentRoutedNamespace()
- Gives you the current routed namespace, if any
Last updated