Joomla 4.1 will support templates with the ability to create child template. Actually the code already exists since 4.0 and this Pull Request. The UI was missing anything meaningful prior to 4.1 so although the new mode technically was supported it wasn't exposed to the end users. The missing UI part will be introduced with Pull Request.
Child templates basically are templates with only one file: templateDetails.xml
.
A child template has one field named parent in the templateDetails.xml
that holds the name of the parent template, eg: <parent>cassiopeia</parent>
.
The MVC part of Joomla is already aware how to handle child templates and it works based on inherritability. Eg if index.php
doesn't exist in the child the parent one will be used. This pattern is applied to the direct entry points of the template the overrides and also the static file overrides.
No, the feature is opt-in, so a template in order to be enabled for child templates should have a field name inheritable with a value 1 in the templateDetails.xml. On top of that the static assets are expected to be stored in the media folder rather than the template folder. There is a converter that aims to convert templates with very little effort: https://github.com/dgrammatiko/convert-template
Depends on your actual code, but here's a list of possible ones:
- Static assets with template relative paths: eg
$path = $this->baseurl . '/templates/' . $this->template . '/images/logos/brand-large.svg';
should be written as'media/templates/administrator/atum/images/logos/brand-large.svg';
- PHP includes shouldn't use the template name from the variable
$this->template
for the path so the child could load the correct file: eginclude JPATH_ADMINISTRATOR . '/templates/' . $this->template . '/base.php';
should be written asinclude JPATH_ADMINISTRATOR . '/templates/admin2021/base.php';
The project will try it's best to keep maximum backwards compatibility. That said the template file editor is expected to have some significant changes so if you have functionality that extends that view please be aware.
The idea behind the child templates was to enable template updates without breaking any user modified files. In essence this means a safer environment for the template authors but also for the end users.