Closed dannystarkDE closed 5 years ago
ah sorry.. :) that's working by default...
my controller wasn't working 😄
Hey, good that you've solved it. :)
Hey, i have the same question, but did not find the answer on my own like @dannystarkDE :
I have a controller which returns data, that i want to access with twig:
.../controller.php: return [ 'alert' => $alert, 'data' => $data ?? false, 'success' => $success ?? false ];
How is it possible to access this data with twig?
Thanks for the plugin and help!
Hey @Paulexe, your controller must be named like the template you want to pass those variables to. This controller would only work for a template called controller.twig
.
In controller.twig you would be able to access those variables for example by using the following:
{{ alert }}
See here: https://getkirby.com/docs/guide/templates/controllers
hey,
i am relatively new to kirby and PHP, and have a question about the contact form. how can i access the variables $alert etc. in the template with twig?
I am currently trying to integrate a contact form on the homepage, but I lack any understanding of how to access the data within Twig.
thanks for your help.