Search code examples
htmltwiggravitygravity-forms-plugingrav

GRAV custom fields / html blocks / custom theme templates


I'm trying to build a static website using the GRAV CMS. So far, I've been creating *.html.twig files and associating a single page to the individual template.

This is how my pages look:

{% block header%}
{% include 'partials/bhss-default-header.html.twig' %}
{% endblock %}

#CONTENT

{% block footer%}
{% include 'partials/bhss-default-footer.html.twig' %}
{% endblock %}

However, my purpose is to have an editor creating pages from the admin interface and adding HTML blocks similar to the custom fields or shortcodes in WordPress. I want this blocks to be filled with text.

I need to mention that my website is built with Semantic-UI, so I'm not using any theme provided by GRAV.

How can I replicate this behavior and what choices do I have ? The website is small at this time, so I can remake every page.

Thank you!


Solution

  • If you want to use editor, you need to build your header and footer as Grav pages in Markdown, not Grav theme's template file in Twig. Example:

    {% block header%}
    {{ pages.find('/my-header').content }}
    {% endblock %}
    
    #CONTENT
    
    {% block footer%}
    {{ pages.find('/my-footer').content }}
    {% endblock %}
    

    my-header and my-footer are 2 pages. You can unpublish these pages to hide them from your menu and forbid direct access to them.