Skip to content

feat: Add article about adding custom header and footer #1753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2025

Conversation

mitelg
Copy link
Member

@mitelg mitelg commented Apr 15, 2025

Due to ESI loading customizing the header and footer does not work like in SW6.6 anymore. This should explain on how to extend them with SW6.7

Closes shopware/shopware#8604

@mitelg mitelg self-assigned this Apr 15, 2025
@mitelg mitelg linked an issue Apr 15, 2025 that may be closed by this pull request
@JoshuaBehrens
Copy link
Contributor

How will dynamic access work for the navigation that way, when no rules (which feels like page data to me) can influence navigation elements? I assume people built similar things and need to understand. Otherwise we will just find plugins in the store, that disable the use of ESI as it is like this in the documentation

@david-strauch
Copy link

@mitelg

While I understand the motivation behind introducing ESI for header and footer – longer cache lifetime and better performance – I see a critical issue that must be addressed, especially in the context of Shopware's large and diverse plugin ecosystem.

The current solution forces developers to either remove ESI entirely or move all customizations into the base_esi_header or base_esi_footer blocks. This creates a dangerous bottleneck in terms of inheritance and extension possibilities.

Let me illustrate this with a realistic scenario:

Example Extension 1 – Shopware 6.6:
A plugin modifies the header and adds some dynamic content before the main header structure:

{% block base_header_inner %}
    {# ... foobar – my dynamic* content before header #}

    {{ parent() }}
{% endblock %}

(dynamic means: custom field output, controller response, login state-dependent content, etc.)

Now, with ESI, this approach breaks.


Example Migration of Extension 1 – Shopware 6.7:
To preserve the customization, the developer decides to inject the content into the new base_esi_header block:

{% block base_esi_header %}
    {# ... foobar – my dynamic content before header #}

    {{ parent() }}
{% endblock %}

So far, so good – until another extension enters the game.


Example Extension 2 – Shopware 6.7:
Another plugin, independently developed, follows the recommendation from the documentation and replaces the entire block with a static include:

{% block base_esi_header %}
    {% sw_include '@Storefront/storefront/layout/header/header.html.twig' %}
{% endblock %}

As a result, Extension 1 and its content are gone.


This is a real issue, not just a theoretical one. In a plugin-rich environment like Shopware's, this pattern creates massive incompatibilities and makes it impossible to rely on layered inheritance – one of the key features of the Twig templating system and the Shopware theme system.

  • The base_esi_header block is now a hotspot – every plugin that touches the header needs to deal with it.
  • There’s no room for safe inheritance unless every plugin behaves like a good citizen – which can’t be guaranteed.
  • This will cause plugin breakages.

Therefore, I ask you to actively address this issue again.
shopware/shopware#8136

And if that is not an option, add more granular blocks within the ESI-loaded header and footer templates. For example:

  • base_esi_header_before
  • base_esi_header_inner
  • base_esi_header_after

This would mirror the previous block structure and allow multiple plugins to safely inject their content without overwriting each other or breaking ESI logic.

This ESI approach, while technically elegant, has not been fully thought through in terms of developer experience and plugin compatibility. Given Shopware's commitment to extensibility, this decision needs to be revisited – or at least softened – before 6.7 reaches stable release.

Let’s not sacrifice the flexibility of the system in favor of a performance gain that might only be marginal in real-world setups.

@david-strauch
Copy link

Another important point to consider is how long this kind of implementation can realistically hold in a system as modular and extensible as Shopware.

Given the sheer number of extensions and custom implementations out there, it’s very likely that every second or third project will contain at least one plugin that modifies the header or footer in a way that renders the ESI include unusable or is forced to override it.

If enough plugins disable or bypass the ESI logic to keep their features working, the intended performance benefits are quickly lost across the ecosystem – and the ESI integration becomes more of a theoretical construct than a practical solution.

In other words: If this approach isn’t easily extendable and conflict-safe, it won’t be widely adopted. And if most developers end up turning it off, the effort might have been in vain.

@mitelg
Copy link
Member Author

mitelg commented Apr 16, 2025

hey @david-strauch

thanks again for your valid feedback. We will revisit this again, as already mentioned in the issue.

@mitelg
Copy link
Member Author

mitelg commented Apr 16, 2025

How will dynamic access work for the navigation that way, when no rules (which feels like page data to me) can influence navigation elements? I assume people built similar things and need to understand. Otherwise we will just find plugins in the store, that disable the use of ESI as it is like this in the documentation

@JoshuaBehrens Dynamic Access works out of the box. As soon as a rule is applied, the cache is disabled (cart and customer stuff)

@JoshuaBehrens
Copy link
Contributor

@JoshuaBehrens Dynamic Access works out of the box. As soon as a rule is applied, the cache is disabled (cart and customer stuff)

A bit sad but I can understand, that one does not want to have super many permutation of rule ids in cache keys

@mitelg mitelg marked this pull request as draft May 7, 2025 12:18
@mitelg mitelg force-pushed the feat/add-header-extension-docs branch from 381184e to f9d7449 Compare May 12, 2025 13:45
@mitelg mitelg marked this pull request as ready for review May 12, 2025 13:46
@mitelg mitelg force-pushed the feat/add-header-extension-docs branch from f9d7449 to de5ecdf Compare May 12, 2025 13:49
@mitelg mitelg force-pushed the feat/add-header-extension-docs branch from de5ecdf to 5ebcb0a Compare May 12, 2025 13:52
@mitelg
Copy link
Member Author

mitelg commented May 12, 2025

hey @JoshuaBehrens @david-strauch

I updated the article due to the latest changes I made here: shopware/shopware#8827

Would be cool, if you could have a look again

@david-strauch
Copy link

@mitelg For me, this works. I'm glad we found such a good solution. 🙌

Thanks to everyone for looking into this and coming up with a solution.

@mitelg mitelg added the v6.7 label May 13, 2025
Copy link
Contributor

@Isengo1989 Isengo1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the PR @mitelg 👍

@mitelg mitelg merged commit 0f1b05b into next-6.7 May 13, 2025
6 of 7 checks passed
@mitelg mitelg deleted the feat/add-header-extension-docs branch May 13, 2025 08:50
bojanrajh added a commit that referenced this pull request Jun 18, 2025
* feat: v6.7.0.0-dev

* NEXT-37105 - new payment handling for 6.7 (#1426)

Co-authored-by: Bojan Rajh <[email protected]>

* typo: Update add-payment-plugin.md (#1611)

* typo: Update add-payment-plugin.md

fixes typo on calling the transactionStateHandler obj

* fixes 3 more same typo

* Http cache clearing (#1693)

* Update cache clearing methods

* Clarify versions

* Fix markdown

---------

Co-authored-by: Micha <[email protected]>

* docs: adjust performance tweaks for 6.7 update (#1705)

* docs: enhance licensing and feature management information in commerc… (#1675)

* docs: enhance licensing and feature management information in commercial plugin

* Apply suggestions from code review

Co-authored-by: Micha Hobert <[email protected]>

---------

Co-authored-by: Micha Hobert <[email protected]>

* NEXT-39755 - Update messenger docs to use default symfony bus (#1584)

* feat: remove workflows (#1698)

* feat: remove workflows

* fix: guidelines

* fix: guidelines

* fix: lint

* Update add-custom-commands.md (#1699)

There was one class missing in the "use Symfony\Component\Console\Attribute\AsCommand" class, which is generating an error like the following:

The command defined in "NameSpace\Of\MyClassCommand" cannot have an empty name.

* adhoc/update-hash

* Update add-menu-entry.md (#1702)

* FIX: wrong key in object-stroage config in filesystem.md (#1696)

"options:" does not exist anymore in config and was not removed here but later in the docs. This will result in an "access denied" error as soon as file system calls are made, despite valid credentials.

* docs: adjust performance tweaks for 6.7 update

* Fix wordlist and markdown

---------

Co-authored-by: Shyim <[email protected]>
Co-authored-by: Micha Hobert <[email protected]>
Co-authored-by: Aydin Hassan <[email protected]>
Co-authored-by: Bojan Rajh <[email protected]>
Co-authored-by: Mohammad Bharmal <[email protected]>
Co-authored-by: Philipp Bucher <[email protected]>

* fix: Links to manifest file for Shopware 6.7 (#1708)

* fix: unlock adr to trunk

* [create-pull-request] automated change (#1712)

Co-authored-by: shopwareBot <[email protected]>

* Update add-cookie-to-manager.md (#1719)

Fix wrong namespace in example.

* update admin asset usage guide (#1714)

* fix: Improve article about adding data to the storefront (#1725)

* fix: Improve article about adding data to the storefront

* Update guides/plugins/plugins/storefront/add-data-to-storefront-page.md

Co-authored-by: Albert Scherman <[email protected]>

* chore: Update the articles where a StorefrontController is used (#1734)

* chore: Update the articles where a StorefrontController is used

Using `setTwig` is no longer necessary.
References about header and footer in custom page objects are also removed. As they are no longer part of the generic page.

* fix code blocks

* fix: broken rendering

* chore: remove ADR change

* chore: add code groups

---------

Co-authored-by: Micha <[email protected]>

* Explain new twig changes while keeping appropriate warnings (#1500)

* Explain new twig changes while keeping appropriate warnings

* Update resources/references/storefront-reference/twig-function-reference.md

* chore: reformat tables and intro

---------

Co-authored-by: Micha Hobert <[email protected]>

* docs: add caching guide (#1743)

* docs: add caching guide

* Update guides/plugins/plugins/framework/caching/index.md

Co-authored-by: Copilot <[email protected]>

* Fix spellcheck

* http code block

* chore: grammar, language and styling

* chore: adjust headlines / toc

* Address CR comments

* Clearify info

* Update guides/plugins/plugins/framework/caching/index.md

Co-authored-by: Michael Telgmann <[email protected]>

* Update guides/plugins/plugins/framework/caching/index.md

Co-authored-by: Michael Telgmann <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Micha <[email protected]>
Co-authored-by: Michael Telgmann <[email protected]>

* chore: add updated AppScript reference (#1726)

* feat(theme-config): Add documentation regarding labels and helpTexts for the theme manager (#1770)

* fix: getRequest is not part of HttpCacheKeyEvent (#1768)

* feat: Add article about adding custom header and footer (#1753)

* chore: Improve current articles regarding header and footer changes

* feat: Add article about adding custom header and footer

* chore: grammar-and-language

---------

Co-authored-by: Micha <[email protected]>

* Update guides/plugins/plugins/storefront/customize-templates.md

* chore: remove-watcher (#1771)

* docs: add section about disabling scheduled sitemap generation (#1794)

* docs: add section about disabling scheduled sitemap generation

- Explain that sitemap generation can block the message queue
- Show how to disable the scheduled task
- Provide example cronjob setup
- Available starting with Shopware 6.7.1

Related to shopware/shopware#10403

* fix: markdown linting and add cronjob to wordlist

- Add blank line before list to fix MD032 linting error
- Add 'cronjob' to .wordlist.txt for spell-check

* chore: version-consistency

---------

Co-authored-by: Micha <[email protected]>

* docs: context gateway (#1789)

* docs: context gateway

* docs: add reviewer feedback

* fix: linting

* fix: remove lock files

* Update guides/plugins/apps/gateways/context/command-reference.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

* Update guides/plugins/apps/gateways/context/context-gateway.md

---------

Co-authored-by: Su <[email protected]>

* feat: Hint that hardcoded prefixes are no longer necessary (#1799)

---------

Co-authored-by: Lennart Tinkloh <[email protected]>
Co-authored-by: Panagiotis Koursaris <[email protected]>
Co-authored-by: Aydin Hassan <[email protected]>
Co-authored-by: Micha <[email protected]>
Co-authored-by: Jonas Elfering <[email protected]>
Co-authored-by: Shyim <[email protected]>
Co-authored-by: Mohammad Bharmal <[email protected]>
Co-authored-by: Philipp Bucher <[email protected]>
Co-authored-by: Michael Telgmann <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: shopwareBot <[email protected]>
Co-authored-by: Marc <[email protected]>
Co-authored-by: Benedikt Schulze Baek <[email protected]>
Co-authored-by: Albert Scherman <[email protected]>
Co-authored-by: Joshua Behrens <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Max Stegmeyer <[email protected]>
Co-authored-by: Marcel Brode <[email protected]>
Co-authored-by: tinect <[email protected]>
Co-authored-by: Su <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document header and footer template extension with ESI
5 participants