Skip to content

Inherited theme : make it possible to customize specific blocks from base.html.twig #97

Description

@olivierdalang

Hi !

When building a theme that inherits Antimatter, I think there's no clean way to customise a specific block of the base template.

You can only create a partials/base.html.twig file in the subtheme to overwrite the base layout, but then you overwrite the whole file (which means you have to copy all the content of the base theme, which is bad in terms of updatability).

A much cleaner way would be to be able to override a specifc block only. This would be very easy to achieve with a small modification to Antimatter. It would need to move the content of partials/base.html.twig to a new partials/abstract_base.html.twig, and to set the content of partials/base.html.twig to {% extends 'partials/abstract_base.html.twig' %}.

Then, child themes could override some blocks, by providing their own partials/base.html.twig, containing for example :

{% extends 'partials/abstract_base.html.twig' %}

{% block footer %}
<footer id="footer">
    MY FOOTER
</footer>
{% endblock %} 

This way, if the antimatter theme is updated, all the rest of the base layout is kept.

I'm not completely sure, but I think this would be perfectly retro-compatible. What do you think ? If you like it, I can issue a PR.

Bests,

Olivier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions