What happened?
Description
We use a template field element to render where particular elements are referenced (e.g. show a list of blog posts referencing a particular product). To keep things stylistically homogenous, I used {% hook "cp.elements.element" %} to render a link to the elements. In Craft 5, this hook is deprecated and we're told to use the Cp::elementCardHtml() function; however, this function is not available in the site template mode, which is what's used for rendering these templates.
Here's the Twig code for the embedded template: https://gist.github.com/Mosnar/f8aebd38fc4548dc9249631401666fc9
Steps to reproduce
- In a field layout "Template" element, use
{% hook "cp.elements.element" %} (or insert code from attached Gist)
- See deprecation warning logged
Expected behavior
Ideally, I'd like to be able to use elementCardHtml() in the Template field layout element without needing to write a custom plugin or module.
Craft CMS version
5.5.3
PHP version
8.2.26
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
What happened?
Description
We use a template field element to render where particular elements are referenced (e.g. show a list of blog posts referencing a particular product). To keep things stylistically homogenous, I used
{% hook "cp.elements.element" %}to render a link to the elements. In Craft 5, this hook is deprecated and we're told to use theCp::elementCardHtml()function; however, this function is not available in thesitetemplate mode, which is what's used for rendering these templates.Here's the Twig code for the embedded template: https://gist.github.com/Mosnar/f8aebd38fc4548dc9249631401666fc9
Steps to reproduce
{% hook "cp.elements.element" %}(or insert code from attached Gist)Expected behavior
Ideally, I'd like to be able to use
elementCardHtml()in the Template field layout element without needing to write a custom plugin or module.Craft CMS version
5.5.3
PHP version
8.2.26
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response