I have a Repeater field inside a Repeater field.
In the top field the Template code is
[[$Bereiche.Outer? &headline= '[[+headline]]' &program_1= '[[+program_1]]' ]]
This works fine.
“program_1” is also a repeater field (nested). It has three inputs (2 text, 1 dropdown with SNIPPET binding). I can access those fields in this template as intended with:
[[+val_1]] [[+val_2]] [[+val_3]]
The rendered template from the nested field is displayed in the first field.
But when I add some specific characters to the nested template, the complete CB contents won’t show. The rest of the page renders, but CB returns empty for +content.
So far I found these characters to cause the issue:
= & ?
I have no idea why this happens.
Are you actually using the
' style quotes, or did you only change that to make it show up on the forum? If you’re using that, swap them out with the ``` (backtick) style quotes and that should make it better. If you’re trying to make it show up prettier on the forum, use 3 backticks to open and end a code block.
What you could look at is the quick update after saving the resource, to see how ContentBlocks rendered it into your content field. If that looks alright, which I hope it does, you may be running into restrictions of the MODX parser.
While it’s not uncommon for people to use chunk tags in the templates like you are doing, that does come with the downside of nesting things quite deeply (especially if your chunk contains other chunks, and so on) and the MODX parser doesn’t always deal nicely with that. In the 2.5 and 2.6 MODX releases there have been a couple of tweaks related to that. The characters you mention,
=&?, do fit with special characters in the parser.
I didn’t know about the triple backticks. I’m using the proper backtick syntax in the code.
You we’re right about the usage of chunks. I pasted the actual code into the CMS and now it works fine. Who’d a thought!
So I guess before finishing CB 2.0, you just have to do a quick rewrite of the MODX parser…
Thanks for the help!
I’m considering moving to Twig in ContentBlocks 2 to the parsing more powerful, and predictable. Some of the more powerful fields like the Repeater could benefit lots from that, but it is an extra learning curve for people.
Commerce uses Twig at the moment, and that seems to be working fine for people, so maybe the MODX world is ready for some more twig?
It’s probably a good thing for adaption to keep it easy for all. But we also like to be powerful, like Iron Man or Wolverine, you know?
But for right now: any pointers on how nested I can get with all the repeaters? Right now I would like to try:
Repeater inside repeater inside repeater inside repeater.
What do you say, Professor Xavier?
I’ve tested repeaters like 3 levels deep with no issues (other than the UI getting increasingly confusing with each layer you add). So long as you avoid chunks for the templates (to avoid the issue discussed here), the number of repeaters you can use within repeaters is primarily limited by common sense.
I don’t get paid for common sense!
(But it can get a bit confusing with all the 'Add Item’s)
I’m having fun though!