2

I'm using the Grav CMS and would like to have a block of global content present on each page. In other words, every page on the site will have this same block of content (near the footer). I'd like the content of this block to be editable similar to other pages, through a .md file. Instead of hardcoding the content of this block into the base.html.twig (or another) template the content should be editable through a .md file similar to other pages.

One option, use find() to pull the content of the page I want into each page. The downside to this is that I don't want this page to appear in the navigation. If there is a way to hide a page from the navigation this might work however.

What is the recommended way to accomplish this?

Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184
  • Why not use the 'plugin' structure to solve this? Implement the necessary code as a plugin and so you can activate this on you each pages `.md` if you want show it. – JoGe Jul 29 '15 at 15:39

1 Answers1

4

I solved this by creating a variable containing the page object from the page I wanted. Within the base.html.twig template I did the following:

{% set secondpage = page.find('/_page_url') %}
{{secondpage.content}

The _page_url is hidden due to the _, but still editable as a normal page.

Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184