Grav: Include page content of another page

Created on 28 Oct 2016  路  4Comments  路  Source: getgrav/grav

Hi folks! Is it possible to include the content of a page into another page? I don't get any useful results, when I'm searching this question.

I have a page with "about us" content, which should included as a modal in every page. So I need to include the {{ page.content }} from the "about us" page into the base.html.twig. Is this possible?

Regards Philip

question

Most helpful comment

Very possible: https://github.com/getgrav/grav-plugin-page-inject is the easiest way. Alternatively you can use twig:

{{ page.find('/some/other.page').content }}

If you want to include the same twig template with the same content on every page, you can put do that right in the twig:

{% set page = page.find('some/other/page') %}

<div id="about-us">
  {{ page.content }}
</div>

All 4 comments

Very possible: https://github.com/getgrav/grav-plugin-page-inject is the easiest way. Alternatively you can use twig:

{{ page.find('/some/other.page').content }}

If you want to include the same twig template with the same content on every page, you can put do that right in the twig:

{% set page = page.find('some/other/page') %}

<div id="about-us">
  {{ page.content }}
</div>

Perfect! Thank you very much, works fine :-)

Is the same possible with modular content?

Hi @parijke , yes it is. If I remember correctly for the Page Inject plugin just added the underscore ('_') character to insert modular content. For example:

[plugin:content-inject](/ux-techniques-guide/_user-interface-design)

Simarily, for the page find command it would be:

{{ page.find('/ux-techniques-guide/_user-interface-design').content } }}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabrizioT picture fabrizioT  路  26Comments

giansi picture giansi  路  17Comments

marktaylor46 picture marktaylor46  路  26Comments

balajmarius picture balajmarius  路  17Comments

ThinkDevStudios picture ThinkDevStudios  路  17Comments