Send data from route to model or controller

I have a route which matches a pattern and ends like this (a shorter version of it):

$data = array(
  'template' => 'image',
);
site()->visit($page->uri(), 'en');
return array($page->uri(), $data);
die;

I’ve read some threads about it but not found a solid solution to it.

Questions

  1. How can I send the data in a route to a model?
  2. As a bonus, add how to do the same to a controller?
  3. Models are loaded first and then controllers inherit what comes out of that?
  1. You can set a property of the page object: $page->something = 'some value'
  2. Hm, that’s more difficult. But the controller should also have access to the same page object with the same property. Haven’t tested that though.
  3. I don’t really understand the question to be honest. Controllers don’t inherit from the page model. What exactly do you mean?
1 Like

I had it working, but the solution was really ugly to get around all the issues it created. Therefor I rewrote most of the code to make it more like the standard way of how Kirby works.

  1. I tried it anyway and it worked to add stuff to the page object. I no longer have any routes so I’ve not tried it with routes.