Skip to content
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

Wartungstemplate anpassen in Contao 5.5 #1549

Open
CMSworker opened this issue Mar 5, 2025 · 12 comments
Open

Wartungstemplate anpassen in Contao 5.5 #1549

CMSworker opened this issue Mar 5, 2025 · 12 comments

Comments

@CMSworker
Copy link
Contributor

CMSworker commented Mar 5, 2025

Beim Update auf Contao 5.5.2 war mir aufgefallen, dass das angepasste Wartungstemplate (Anleitung Logo ändern) in /templates/bundles/ContaoCoreBundle/Error/layout.html.twig nicht mehr greift.

Im Core hat das Template einen Unterstrich im Dateinamen, aber eine Anpassung des eigenen Templates in /templates/bundles/ContaoCoreBundle/Error/_layout.html.twig (mit Leeren des Prod-Cache) hat das Problem nicht behoben.

Ich nehme an, das kam mit der Einführung des "Template Studio" in Contao 5.5.0?

Mein erster Versuch, im Backend > Template Studio das Template unter "error > error/_layout" komplett zu überschreiben, hat nicht geklappt (hatte den Inhalt des Ausgangstemplate aus Schritt 1 komplett kopiert, dann auf "Create your Template" geklickt, den kopierten Code dort eingefügt und gespeichert -> es wurde danach wieder nur das Standard-Überschreiben-Template angezeigt "@ extends... Adjust how any blocks of parent or used component templates are rendered.")

Ich habe daraufhin in einem externen Editor die Datei /template/error/_layout.html.twig bearbeitet, den kompletten Original-Code dort eingefügt, meine Anpassungen gemacht, gespeichert und danach im Manager den Prod-Cache geleert, das hat dann geklappt und im Template Studio wird nun auch angezeigt "This template overwrites all previously defined content because it does not extend from @ Contao/error/_layout.html.twig".

Ich vermute, das betrifft alle, die ein angepasstes Wartungstemplate verwenden. Vielleicht sollte auch zusätzlich zur Anleitung, wie man das Wartungstemplate anpasst, auch auf der Seite "Update und Migration" ein Hinweis ergänzt werden, dass mit dem Update auf 5.5 Wartungstemplates anders angepasst werden müssen?

@fritzmg
Copy link
Contributor

fritzmg commented Mar 5, 2025

The documentation is wrong here as this is not the correct template (and never was). I will create a PR for the documentation accordingly.

There have been no changes in Contao 5 regarding the error templates in Contao 5.5 as far as I am aware.

@fritzmg
Copy link
Contributor

fritzmg commented Mar 5, 2025

Im Core hat das Template einen Unterstrich im Dateinamen

That is not the case btw., see the available templates here: https://github.com/contao/contao/tree/5.5.2/core-bundle/templates/Error

@CMSworker
Copy link
Contributor Author

CMSworker commented Mar 5, 2025

Basiert das nicht auf dieser Datei?
https://github.com/contao/contao/blob/5.5.2/core-bundle/contao/templates/twig/error/_layout.html.twig

Um Missverständnisse zu vermeiden: Ich meinte schon das allgemeine Error-Layout-Template, nicht nur speziell "Service unavailable"...

Also beispielsweise, um in allen Fehlerseiten ein angepasstes Logo zu haben, CSS-Styles abändern... vor 5.5 hat das wie derzeit in der Anleitung beschrieben funktioniert. Um solche Anpassungen mit Twig-Vererbung machen zu können (ohne das komplette Error-Layout-Template überschreiben zu müssen), wären im Contao-Standard-Error-Layout-Template weitere Blöcke nötig (z.B. innerhalb der < style >-Sektion, am Anfang direkt nach < body >, um das Contao-SVG-Logo...)

@fritzmg
Copy link
Contributor

fritzmg commented Mar 5, 2025

Actually the documentation also mentions adjusting all error templates accordingly.

The change was introduced in #7659.

@contao/developers the discussed BC layer does not seem to work then - nor can it really work, can it? The new error templates only use the new template namespace, so the old templates can never really have any effect.

@aschempp
Copy link
Member

aschempp commented Mar 6, 2025

I think the BC layer was incorrectly built. It adds BC if someone rendered the error template manually, instead of adding BC if someone changed the original template.

@m-vo
Copy link
Member

m-vo commented Mar 6, 2025

I don't understand the issue. The same templates as before are rendered from the code. They just got a new parent template they extend from (the new location).

@fritzmg
Copy link
Contributor

fritzmg commented Mar 6, 2025

@m-vo this is what we have documented:

Customize logo

In this example we do this for all error templates. For an update-safe adaptation we copy the original template vendor/contao/core-bundle/templates/Error/layout.html.twig to templates/bundles/ContaoCoreBundle/Error/.

This does not work anymore since contao/contao#7659. A templates/bundles/ContaoCoreBundle/Error/layout.html.twig will be ignored.

@Toflar
Copy link
Member

Toflar commented Mar 6, 2025

There's no BC promise for templates anyway so why don't we just fix the docs?

@fritzmg
Copy link
Contributor

fritzmg commented Mar 6, 2025

@Toflar because we decided to have the BC layer in order to not make things unnecessarily difficult for users. See

If the BC layer does not work as intended and we do not want to fix this, we can just remove it anyway.

@fritzmg
Copy link
Contributor

fritzmg commented Mar 6, 2025

As discussed in the Contao call we want to try to fix the template inheritance so that this will work in a BC way again.

@m-vo
Copy link
Member

m-vo commented Mar 7, 2025

See contao/contao#8185

The documentation should still be updated. For new installations (5.5+) you would rather adjust the templates directly from the @Contao namespace.

@fritzmg
Copy link
Contributor

fritzmg commented Mar 7, 2025

The documentation should still be updated.

Yes 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants