Feature #70483


Typoscript join for ContentObjectArray (COA)

Added by Simon Schaufelberger almost 9 years ago. Updated almost 9 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


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).

Actions #1

Updated by Georg Ringer almost 9 years ago

  • Subject changed from Typoscript join for ContentObjectArray (CAO) to Typoscript join for ContentObjectArray (COA)
Actions #2

Updated by Mathias Brodala almost 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.

Actions #3

Updated by Simon Schaufelberger almost 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:

  infinite: true,
  slidesToShow: 3,
  slidesToScroll: 3

Actions #4

Updated by Georg Ringer almost 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


Also available in: Atom PDF