Ideally. I could have the subpage of find in the panel. So advisor/find would have a template assigned. But if template not assigned and domain doesn’t exist. Then it would hit another template.
I see, what you could do is return the same page (template), but send a variable to the controller that depending on the value of that variable then includes either the snippet for the list of advisors or the single advisor. If value = “find” return list, else return agent.
c::set('routes', array(
array(
'pattern' => 'advisor/(:any)',
'action' => function($uid() {
// return the $uid variable to your controller, as explained in the docs
// in the controller, pass to template, in template either return find snippet, or agent snippet
}
)
));
Also, when returning the template. How to pass those variables into the template from the controller. We had this issue before where the system can’t pass variables from the controller into the template?
Why should it go back too the advisor template. What I’m suggesting is to return the find page. The controller for the findpage get the $uid and based on that value, returns one or the other snippet in the template.
Yes, you can also return a template, but then you have to pass all the data to the template, including the site and kirby objects. And you have to pass all that down to all snippets, ie. the header, footer snippets etc.
See the documentation for tpl::load()and examples here on the forum
I used this and it redirects to the page I want. So I can manipulate from there. However. I can pull the url off the domain. But if I can parse it in the router and get the value from there. That would be cool. However, when I try and use the $data in the template. It doesn’t work.
In your template, you will not have access to $data in this case, but to $site, $kirby, $pagesand$page, but$pageis not a page in your case, because the page doesn't exist (at least not if(:any)` is an agent.