On a complex site we have found a weird parsing issue with “Layout” field type. Tried to strip it down to most simple case. Test scenario:
- several resources (e.g. blog posts) with image Template Variable (e.g. blogImage)
- CB field (e.g. BlogList, type doesn’t matter) using getResources, with template reffering to image
[[+tv.blogImage]]
- Blog list resource with single BlogList field
This works as expected, even on very complicated layouts and templates. As expected, getResources snipped call is left unparsed by CB upon save (inspected using QuickEdit of the resource)
Now the trouble:
- create Layout field. Field template can be anything, for testing purposes some simple string. Doesn’t even need to contain
[[+value]]
reference to nested layouts - PREPEND Layout field to BlogList field in Blog list resource. Doesn’t matter if any layouts inside Layout field are used.
Upon save, getResources snippet call is parsed (snippets should be left intact). Reference to image path in parsed content is missing Media source base path, thus having wrong url.
Order of fields in Blog list resource matters! Only fields AFTER Layout field are affected. Seems like every CB field after the Layout field get it’s template parsed including snippet calls upon save, unfortunately not in a correct way.
There is a related error in log for every parsed Template variable image upon resource save:
(ERROR @ .../core/src/Revolution/modTemplateVar.php : 331) PHP warning: Undefined array key "class_key"