Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include page content of another page #1139

Closed
philipisik opened this issue Oct 28, 2016 · 4 comments
Closed

Include page content of another page #1139

philipisik opened this issue Oct 28, 2016 · 4 comments
Labels

Comments

@philipisik
Copy link

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

@rhukster
Copy link
Member

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>

@philipisik
Copy link
Author

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

@parijke
Copy link

parijke commented Oct 29, 2017

Is the same possible with modular content?

@paulhibbitts
Copy link

paulhibbitts commented Oct 29, 2017

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 } }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants