Where is the place to introduce a command such that when you enter on a page-by-page basis the following into frontmatter: hide_navigation: true - in this case, the navigation would disappear? I have no clue about twig, fyi, just a good feel for html, css and markdown.
Hi @werdi, I actually do something very similar for several of my open education and publishing projects (Bootstrap4 Open Matter and Quark Open Publishing theme) for Grav so Grav content can be ‘chromelessly’ embedded into other systems like LMS etc.
In general, you want to usually skip the Twig responsible for displaying the menu, header, etc based on a variable (either page header or in my case a theme option or URL flag).
Here are some example Twig files which might help:
By “chromeless” I mean presenting a web page with content only, no navbar, sidebar, footer, etc. By ‘LMS’ I mean a Learning Management System, which is used by a lot of universities for providing course content to students.
For the functionality that you are describing you will need to use custom Twig for that. However, if you use one of my themes such as Bootstrap4 Open Matter or Quark Open Publishing the ability to hide the navbar/sidebar/footer is already included in the theme (but not to hide it page-by-page by frontmatter but rather by the URL used to embed the page).
@werdi, Based on a child theme of Antimatter, I have created a sample to hide/show the entire header or only show/hide the navbar.
To hide/show a block of code based on the frontmatter of a page, you do the following in general:
In page file header you set the required variable:
---
hide_navigation: true
---
# A page without navigation
In Twig:
{% if not page.header.hide_navigation %}
{# Show this if page.header.hide_navigation is not defined, or is false #}
{# Here goes the HTML building your navigation bar #}
{% endif %}
If we want to implement hide/show header/navigation in a child-theme based on Antimatter, we could do the following:
In frontmatter of page hiding navigation (but keeping the navbar with language-switcher):
---
hide_navigation: true
---
# I have no navigation
In frontmatter of page hiding entire header (including the navigation):
---
hide_header: true
---
# I have no header
In twig /user/themes/werdi_theme/templates/partials/base.html.twig, we surround the blocks {% block header %} and {% block header_navigation %} with the proper if-statements to hide/show the header resp. navigation. Note, I keep the language switcher.
@anon76427325 This sounds like exactly what I’m looking for. I will have to take a few days to try it out during next week. For now, thanks, I’ll get back and let you know.
As to the language switcher, I mean to have the twig in place already to toggle it on and off. Correct?
What I meant to say is that when I had the site modified, I asked for a toggle for the langswitcher: “hide_langswitcher: true” or something like that. I’ve not really used it, but it’s there. I was just missing the tools to hide the other parts: navigation and header.