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

Footer data from file.md

Started by Muut Archive 10 years ago · 4 replies · 488 views
10 years ago

In base.html.twig I want to get data from a file into the footer. I tried creating a page called footer.md and included footer.html.twig created in the template. But this is not working. Is there a better way to do this?

10 years ago

Thank you for replying. Is the path in page.find currently at partials folder as the base.html.twig is stored there?
If footer.md page stored in pages folders should the path be (../../../pages/footer.md)

10 years ago

Don't forget to activate your debugger and dump the page to be sure you got the right one.

I have the same problem than @mptyi, I created a footer.html.twig, wanted to call it in base with a specific page.

{% include 'modular/footer.html.twig' with {'page': page.find('/footer')} %}

Even though the code is right (the debugging tool tells me that the page is correct), the footer is not resolved with the data of footer, but of base. What am I doing wrong ?

10 years ago

Okay, I solved it... 'page' is a variable that is passed to the footer template. To access the data of page in the footer template, just prefix it with 'page':

TWIG
 {% for item in page.header.logos %}
        //
    {% endfor %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1368 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago