Project

General

Profile

Actions

Feature #70483

closed

Typoscript join for ContentObjectArray (COA)

Added by Simon Schaufelberger over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
Start date:
2015-10-08
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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

Actions #1

Updated by Georg Ringer over 8 years ago

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

Updated by Mathias Brodala over 8 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 over 8 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
});

Actions #4

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

Actions

Also available in: Atom PDF