getgrav / grav-theme-quark

MIT License
66 stars 59 forks source link

How to edit footer via Child theme ? #17

Open mohsinkh opened 6 years ago

mohsinkh commented 6 years ago

hi, i just create a new blog in Grav using Quark theme - how I can edit the footer text by using Inheritance I took some concepts from https://getgrav.org/blog/theme-development-with-inheritance but I have no idea - what to write in my child theme - to edit footer.

JOduMonT commented 6 years ago

Actually you will find the footer block is under ./user/themes/quark/templates/partials/base.html.twig

So by making a mytheme than copying base.html.twig into mytheme path (./user/themes/mytheme/templates/partials/base.html.twig) you will be able to change the footer without loosing these change when the grav team will update the quark theme.

Now It brought me the question for Andy (@rhukster); would be not preferable to make a {% include 'partials/footer.html.twig' %} which, I think, will make easier to maintain child theme ?

mohsinkh commented 6 years ago

@jodumont thanks - things worked properly. However, the resulting layout is not properly aligned - i mean it appears as if the stylesheets are not linked/rendered properly. What do you think, I would have missed ?

JOduMonT commented 6 years ago

It's hard to say without a image or a link or code ;) but did you kept everything in the block and only change what was inside the paragraph ?

{% block footer %}
    <section id="footer" class="section bg-gray">
        <section class="container {{ grid_size }}">
            <p>
            INSERT YOUR NEW FOOTER TEXT HERE
            </p>
        </section>
    </section>
{% endblock %}

the original block is here

eisenherzz commented 6 years ago

@mohsinkh maybe you mean #15

marshmn commented 6 years ago

For maintainability, I think that instead of copying ./user/themes/quark/templates/partials/base.html.twig into your theme, it would actually be better to copy ./user/themes/quark/templates/default.html.twig (or similar depending on the type of page, e.g. modular.html.twig etc). You may need to modify multiple files if you have a number of different page types in use.

Given that default.html.twig extends base.html.twig you can then add a {% block footer %} ... {% endblock %} section in your default.html.twig (just add it to the end) and it will override the base file.

Doing it this way will mean that when any changes are made in the parent theme's base.html.twig then these will be reflected automatically in your theme.

aoloe commented 5 years ago

i think this is solved now... i've found a /templates/partials/footer.html.twig...

elfrinjo commented 5 years ago

Would it be possible to have to footer editable like the sidebar? (e.g. overwrite the default footer with content from pages/modules/footer/default.md)

EDIT: Currently it is not possible. But would it make a viable feature/pull request or is it unwanted?

NicoHood commented 4 years ago

I also found it very useful to overwrite the footer. I followed this tutorial:

pages/footer/default.md

---
title: Footer
routable: false
visible: false
---

[Open Source](#) - [Impressum](#) - [Händer werden](#)

Built with [Grav CMS](http://getgrav.org)  
[Course Hub](http://learn.hibbittsdesign.org/coursehub) package by [hibbittsdesign.org](http://hibbittsdesign.org)

templates/partials/footer.html.twig

<section id="footer" class="section bg-gray">
    <section class="container {{ grid_size }}">
      {% set content = pages.find('/footer').content %}
      {% if content %}
        {{ content|raw }}
      {% else %}
        <p><a href="http://getgrav.org">Grav</a> was <i class="fa fa-code"></i> with <i class="fa fa-heart-o pulse "></i> by <a href="https://trilby.media">Trilby Media</a>.</p>
      {% endif %}
  </section>
</section>

@elfrinjo How did you solve it? Do you have a better idea?

marc-odp commented 3 years ago

This is a nice solution. However, I had to write : {{ content | raw }} instead of {{ content }} That is needed for the html tag to be interpreted.