Feature #70483
closedTyposcript join for ContentObjectArray (COA)
0%
Description
I didn't find a good way to do it, so I thought about a new feature:
lib.joinCOA = COA lib.joinCOA { join = , 1 = TEXT 1.value = foo 2 = TEXT 2.value = bar 3 = TEXT 3.value = bas }
will then result in: foo,bar,bas
I need this to create a Javascript config array where it is not allowed to have a trailing comma. I can also not add the comma with a wrap to each item because each item is optional (with required = 1).
Updated by Georg Ringer about 9 years ago
- Subject changed from Typoscript join for ContentObjectArray (CAO) to Typoscript join for ContentObjectArray (COA)
Updated by Mathias Brodala about 9 years ago
The following is an option to solve this:
lib.myCOA = COA lib.myCOA { 1 = TEXT 1.value = foo 1.wrap = |, 2 = TEXT 2.value = bar 2.wrap = |, 3 = TEXT 3.value = bas 3.wrap = |, stdWrap.substr = 0,-1 }
Since you know that the last character is always a comma, you can simply cut it off.
Aside from that a trailing comma is perfectly fine in JavaScript (unless you need to support old IEs). If you are trying to build an JSON encoded string, you should use a userfunction instead which properly calls json_encode
.
Updated by Simon Schaufelberger about 9 years ago
ok that is a solution to my problem. Do you think this is still useful for a feature?
in my case this should be the result:
$('.multiple-items').slick({ infinite: true, slidesToShow: 3, slidesToScroll: 3 });
Updated by Georg Ringer about 9 years ago
- Status changed from New to Rejected
Thanks Mathias for a proper solution!
Dear Simon, I am rejecting this feature as COA is meant to be just a collection of outputs. If you need to create JS output with that, there is a lot more to take care of, like wrapping strings in quotes, ... hope that is ok