Closed OMOSde closed 1 year ago
How can I reproduce that problem? What does “not available” mean in this case? Did you use the newest version (2.4.2) of the extension?
I use version 2.4.2 on Contao 4.13.13.
I have a custom element in a theme folder templates/themea
. This folder is assigned to theme A. If I now use a html5 template everything works. When using Twig the selection of the custom element is possible, but when it tries to render the custom element (backend & frontend) then I get an error message Could not find template
.
I have added two if-queries to the mentioned code places, with which it then works. I could not find any further problems by the adjustment.
Working example:
while ($theme && $theme->next()) {
if ($theme->templates != '') {
if (file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $theme->templates . '/' . $template . '.' . $format)) {
$templates[] = System::getContainer()->getParameter('kernel.project_dir') . '/' . $theme->templates . '/' . $template . '.' . $format;
}
if (file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $theme->templates . '/' . $template . '.html.twig')) {
$templates[] = System::getContainer()->getParameter('kernel.project_dir') . '/' . $theme->templates . '/' . $template . '.' . $format;
}
}
}
if (file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/templates/' . $template . '.' . $format)) {
$templates[] = System::getContainer()->getParameter('kernel.project_dir') . '/templates/' . $template . '.' . $format;
}
if (file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/templates/' . $template . '.html.twig')) {
$templates[] = System::getContainer()->getParameter('kernel.project_dir') . '/templates/' . $template . '.' . $format;
}
contao-rocksolid-custom-elements/src/Template/CustomTemplate.php
at line 66
ce_text.html.twig seems to work in theme folders, but custom elements only work in the root /templates. This needs to be investigated.
In most projects i put the files under contao\templates
because i dont want that they can be edited in the backend. You can override them, but dont change the originals. With html5
this works as aspected but with html.twig
you cant select it from the content- or module-type.
When using Twig the selection of the custom element is possible, but when it tries to render the custom element (backend & frontend) then I get an error message
Could not find template
.
@OMOSde I was able to reproduce and fix that for the backend, but not for the frontend.
Both issues should be fixed by 12082f05c9ea62aa6ae40ea4b1f5b918d725431e
@OMOSde @Tastaturberuf can you please verify if updating to
"madeyourday/contao-rocksolid-custom-elements": "dev-master",
fixes your issues?
Works like a charm. (Contao 5.1)
@ausi I test the fix and this solve the problem for me. (Contao 4.13)
Released as version 2.4.4
Contao 4.13.13 PHP 8.1
Maybe support for twig templates is missing in https://github.com/madeyourday/contao-rocksolid-custom-elements/blob/master/src/Template/CustomTemplate.php (#L68 and #L74).