Skip to content

Fix template path in back-end route documentation#1712

Open
aschempp wants to merge 1 commit intomainfrom
aschempp-patch-1
Open

Fix template path in back-end route documentation#1712
aschempp wants to merge 1 commit intomainfrom
aschempp-patch-1

Conversation

@aschempp
Copy link
Member

No description provided.

@aschempp aschempp requested a review from fritzmg as a code owner January 26, 2026 10:52
@fritzmg
Copy link
Contributor

fritzmg commented Jan 26, 2026

This change isn't really necessary, is it? Within your App any template within templates/ can be rendered without a namespace declaration.

@aschempp
Copy link
Member Author

aschempp commented Feb 3, 2026

That didn't work for me in Contao 5.7 🤔
Maybe @m-vo can clarify?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 3, 2026

I just dropped the given example in the docs verbatim into Contao 5.7 and it worked.

@m-vo
Copy link
Member

m-vo commented Feb 3, 2026

The Symfony filesystem loader also has a concept of namespaces denoted by @, but by default, it internally stores anything in the root template directory under the __main__ namespace and normalizes names without a @ to @__main__/<name>. So this should work in general.

But if the rendered template is in fact meant to be a Contao template, it must also include the @Contao, otherwise none of the features of the Contao Filesystem Loader will be available. Another argument for renaming <project-dir>/templates to <project-dir>/user-templates in Contao 6 btw. to end the confusion about Symfony/Contao templates.

@aschempp
Copy link
Member Author

aschempp commented Feb 4, 2026

The problem most likely was that I place application templates in /contao/templates and not the root folder. It only works if you place it exactly in the root templates directory. Which also wouldn't be the case when developing a custom back end controller in a bundle, right?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 4, 2026

Since this is a normal Symfony Controller the expectation is that you place it in the templates/ folder, regardless of whether it is for the App or a Bundle.

@aschempp
Copy link
Member Author

aschempp commented Feb 5, 2026

so you don't think it is better to have a documentation that just works instead of it works if you follow XY without having XY explained? 🤷 feel free to close then.

@fritzmg
Copy link
Contributor

fritzmg commented Feb 5, 2026

I don't understand, it does work the way it is documented. If we added this it wouldn't work for bundles anymore, so why would we add this?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants