Page.find not working in form data template to send email

I have a custom form with ajax submission on my site and it works great. Handling the response on the site I’m able to use a template and works as it should, I can pull data from wherever I want on the site. When I need to send an email I’m doing the same on the data.html.twig template, but doesn’t seem to work at all. Is there a particular reason for that or should I do something different?

This is how I use it:

{% set child = page.find("/machinery/automatic/" ~ subfolder ~ ‘/’ ~ value) %}

works on the form template, but not on the email body included template.

1 Like

I have same issue. My theory is that the page object is not available in the email body template because there is no page (md file), hence page.find doesn’t work.

I also tried the pages.find method, but it didn’t work either.

Yes, that could very much be the case, I also tried pages.find but no luck.
Did you find a workaround on how to access the data you need?

Yes, I just put it into site.yaml. In our it was actually more logical place than a page. But I would still like to learn how to read page’s header data from anywhere

Interesting, how do you access site.yaml? so that means we have access to site, as well as grav variables, but not pages. In my case I had to access pages images so it was easier to just put the same images in the theme images folder.