How to edit partials from admin panel as page?

Hi there!
Just started working with Grav.
I’ve static html+JS template page which I’m trying to start using with Grav.
There are many HTML raw code which I’ve placed in the page. Making things simpler to manage I put that static html code into partials.

But this code should be manageable - it should be editable.

So, for instance, I’ve partial called footer-form-block.html.twig

In page content it’s called by {% include ‘partials/footer-form-block.html.twig’ %} expression.
How I could edit footer-form-block.html.twig through admin panel?

Hi @01K, my approach to something quite similar (if I understand your post correctly) to this has been to create a Grav page to hold content I want editable in the admin, and then render the content from this page within my Twig template. Perhaps in your case you would need to render that page content using that particular Partial (via the include statement)?

For example, here is how I handle an editable Footer in my Open Course Hub skeleton:

I hope the above might be helpful to you.

1 Like

Thank you! I will try this today

1 Like

I’ve now one issue: all my inserted html code is treated as text and placed into < pre > and < code > tags now.
I’ve turned off twig and markdown options in admin panel for that page, but no luck.
Also, I’ve put the markdown=“1” tag into the root element with markdown on - but also - no success. Any tips?

The block outputs data like this:
{% set videos_block = page.find(’/videos-block’).content %}
{% if videos_block %}
{{ videos_block }}
{% endif %}

without raw filter


Hi @01K, I am not sure why that is happening… where is that ‘block’ you are mentioning and how is it being called? I don’t think you would need to adjust twig and Markdown options from their default.

Hi, @paulhibbitts
I’ve main page called Home. Between html code I wrote this call:

{% set videos_block = page.find('/videos-block').content %} 
{% if videos_block %} 
   {{ videos_block }} 
{% endif %}

Then I’ve created the page videos-block and pasted plain html code in it.
Once the Home page is rendered it outputs mine “old” code with edits and once it comes to the {{ videos_block }} part it outputs all inserted code in < pre > and < code > tags. Very strange behavior…
P.S. I have edited my previous post, of an error in tags display

Maybe try the find without the .content item? Also, sounds like you did already but have you tried videos_block|raw? Sorry, I am not too knowledgable in this particular area…

yes, I’ve tried this - no luck :confused:

ah, it was all in cache…

1 Like

OH! I should have suggested that along the way too! Glad you got it going🙂

1 Like

BTW @01K, what was the final Twig you used?

In a home page, as it was, with raw filter ->
{% set video_b = page.find(’/videos_block’).content %}
{% if video_b %}
{{ video_b|raw }}
{% endif %}
And in video_block page I’ve turned on the Twig checkbox in admin’s panel

1 Like