from the docs I see it is possible to add new template variables in a route’s action. If this action returns an existing page and that page has a controller is it possible to access the added template variable in the controller? Or in other words: can I pass route parameters to a controller?
Thanks in advance.
Cheers
Björn
Update: for the time being I am using the route to redirect and appending the parameter as a query string which I can access inside the controller with get().
Yes. We have different ideas about what a route argument is.
The following is the code that calls kirby::render(). kirby::render() accepts a page as its first argument and then (optionally) a data array. This data array is returned by the route that you provide. In the below code, $response is what you return from your custom route.
Note that if you return a page, kirby::render() is called without a data array at all, hence nothing in your controller’s $args variable. To provide additional arguments you need to return an array where the first item is the name of the page, and the second is whatever you want to provide to your controller.