Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

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

Solved by Jochen Michels View solution

Started by Filippo Masoni 7 years ago · 7 replies · 673 views
7 years ago

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 find.page 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 find.page 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
7 years ago

@filo91:
page.find

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.

7 years ago

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?

7 years ago

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

7 years ago

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.

3 years ago Solution

Hi, this discussion is long ago, but it was not presented a solution.

Since I ran into the same problem, I started a lot of trial and error to include another page (in particular the custom email response to one of several registration forms on the site).

The page object is available via the form object: So the twig expression should looks like:

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

Best wishes

👍 1
3 years ago

@macyogi, It might be better to create a new post with your context. The former OP will probably no longer be around to mark it as solved when a solution gets provided. You might add a link to the new post.

3 years ago

Thank you for the suggestion.
Like @pamtbaau said, it's been a long time, I've found a different solution to the problem and I don't even remember what I did, to be honest. But I've marked that as solved, could be helpful for another time or someone else, although I can't really try if it worked in my situation anymore.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 42 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 47 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 71 2 months ago