What happened?
Description
It's best to explain that via a screenshot:
I was only able to take this screenshot because I disabled to render the "Text" field inside the green "Collapsible Content" card. If I enable that the CP crashes when I try to edit that entry.
What I think happens is:
Craft tries to render the "Collapsible Content" card on the left. If I enable to output the content of "Text" inside the "Collapsible Content" entry type it loops over all elements of "Text". First it's just the paragraph "Level 2 before". Then comes a nested entry. It tries to render that nested entry using its Twig template. That works fine until I use a custom Twig function inside that template. In that case custom Twig functions aren't available and the rendering fails.
The error message literally says:
Twig Syntax Error
Unknown "html_classes" function in "_partials/entry/collapsibleContent" at line 23.
The website itself renders just fine. This happens with functions from twig/html-extra as well from modules containing custom functions.
Steps to reproduce
The steps marked with ❗ directly contribute to the bug appearing.
Setup
- Fresh Craft CMS instance
- Install
twig/html-extra using Composer
- Install CKEditor plugin
Config
- Create a field "Text" with field type "CKEditor"
- Create an entry type "Collapsible Content"
- Handle: "collapsibleContent"
- Add the "Text" field
- Enable "Text" under "Card Attributes" ❗
- Create an entry type "Content"
- Edit the "Text" field again
- Add the "+" button (Add nested content) to the toolbar
- Add "Collapsible Content" under "Entry Types"
- Create a section "Content"
- Section type: "Channel"
- Entry Types: "Content"
- Create template
_partials/entry/collapsibleContent.twig
- Use function
html_classes() inside template ❗
Create content
- Create a new "Content" entry
- Add "Collapsible Content" in "Text"
- Add another "Collapsible Content" inside "Text" of the first "Collapsible Content" ❗
- Actual text content is not required for the error to show up
- Save all changes and create entry
- Open entry again in CP
- → Twig Syntax Error should appear
Expected behavior
Preview card renders in some way. And I think Twig shouldn't be used to render those preview cards because it doesn't get used on the first level. Only when a second level is involved.
Actual behavior
CP crashes when trying to edit an entry setup like above because it cannot find any custom Twig functions. "Twig Syntax Error" in dev mode or "Internal Server Error" in production mode.
Craft CMS version
5.11.1
PHP version
8.5.8 and 8.5.9
Operating system and version
MacOS 26, 27 and Ubuntu 24.04
Database type and version
MariaDB 10.11.14 and MySQL 8.0.46
Image driver and version
Imagick 3.8.1 (ImageMagick 7.1.1-43 / 6.9.12-98)
Installed plugins and versions
- CKEditor 5.7.0
- twig/html-extra 3.28
What happened?
Description
It's best to explain that via a screenshot:
I was only able to take this screenshot because I disabled to render the "Text" field inside the green "Collapsible Content" card. If I enable that the CP crashes when I try to edit that entry.
What I think happens is:
Craft tries to render the "Collapsible Content" card on the left. If I enable to output the content of "Text" inside the "Collapsible Content" entry type it loops over all elements of "Text". First it's just the paragraph "Level 2 before". Then comes a nested entry. It tries to render that nested entry using its Twig template. That works fine until I use a custom Twig function inside that template. In that case custom Twig functions aren't available and the rendering fails.
The error message literally says:
The website itself renders just fine. This happens with functions from
twig/html-extraas well from modules containing custom functions.Steps to reproduce
The steps marked with ❗ directly contribute to the bug appearing.
Setup
twig/html-extrausing ComposerConfig
_partials/entry/collapsibleContent.twightml_classes()inside template ❗Create content
Expected behavior
Preview card renders in some way. And I think Twig shouldn't be used to render those preview cards because it doesn't get used on the first level. Only when a second level is involved.
Actual behavior
CP crashes when trying to edit an entry setup like above because it cannot find any custom Twig functions. "Twig Syntax Error" in dev mode or "Internal Server Error" in production mode.
Craft CMS version
5.11.1
PHP version
8.5.8 and 8.5.9
Operating system and version
MacOS 26, 27 and Ubuntu 24.04
Database type and version
MariaDB 10.11.14 and MySQL 8.0.46
Image driver and version
Imagick 3.8.1 (ImageMagick 7.1.1-43 / 6.9.12-98)
Installed plugins and versions