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.

Content & Markdown

How to get page title from footer when it’s included as a partial?

Started by LeMoussel 6 years ago · 1 replies · 651 views
6 years ago

I’ve tried to look for information in the documentation, but couldn’t find anything on that.
I have a blog page and trying to add a footer as a partial , but the title of the blog page from footer.md is not correctly displayed

I’ve this code to the base.html.twig :
{% include 'partials/footer.html.twig' %}

pages/footer/default.md

YAML
---
title: Footer
routable: false
visible: false
process:
    markdown: true
    twig: true
twig_first: true
---
<h1>{{ page.title }}</h1>

partials/footer.hml.twig:

TWIG
<section id="footer" class="section bg-gray">
    <section class="container {{ grid_size }}">
      {% set footer_content = pages.find('/footer').content %}
      {% if footer_content %}
        {{ footer_content }}
      {% else %}
        <p><a href="http://getgrav.org">Grav</a> was <i class="fa fa-code"></i> with <i class="fa fa-heart-o pulse "></i> by <a href="https://trilby.media">Trilby Media</a>.</p>
      {% endif %}
    </section>
</section>

Whatever the title of blog pages I always have as a title in the footer the title of the page footer, i.e. Footer

is it possible to have the the title of blog pages ?

6 years ago

Hi. If I understand your question correctly, you would like the modular footer to display the title of the 'parent' page, rather than the title of the modular page?

If so, something like this should work:

TWIG
{{ page.parent().title }}

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 99 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 186 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 62 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 257 1 year ago