[TYPO3-dev] Array as data in TS

Christopher Torgalson bedlamhotel at gmail.com
Mon Jan 11 18:30:08 CET 2010


Hi,

On Mon, Jan 11, 2010 at 8:28 AM, Christian Opitz - Netzelf
<christian.opitz at netzelf.de> wrote:
> Hi list,
>
> i have a question regarding TypoScript:
>
> Is there a way to use an array as data source for content objects?
>
> May be an example explains better, what i want to do:
>
> <?php
> //Source array:
> $_GET = Array(
>   'array' => Array(
>      0 => Array('title' => 'foo'),
>      1 => Array('title' => 'bar'),
>      2 => Array('title' => 'baz')
>   )
> );
> ?>
>
> //TypoScript:
> temp.myArrayContent = COA
> temp.myArrayContent {
>   data = GPvar:array
>   wrap = <ul>|</ul>
>   10 = TEXT
>   10.data = title
>   10.wrap = <li>|</li>
> }
>
> <!--Result:-->
> <ul><li>foo</li><li>bar</li><li>baz</li></ul>
>
> Do you think there is a way to realize that with existing TypoScript? If not
> what do you think of an extension that provides a new cObject like for
> instance ARRAY_COBJ?


You can do something almost like this with the typoscript '.split'
function. There's a short example here:
http://www.typo3apprentice.com/blog/single/p/processing-a-list-with-split/

If you can work from a string with some kind of delimiter like ',' or
';', this should work fine to do what you're describing.

It should also be possible for you to do the same with HMENU and a
userfunc--check the special.userdefined property of HMENU [1]


-- 
Christopher Torgalson
http://www.typo3apprentice.com/

[1] http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/8/#id4251386




More information about the TYPO3-dev mailing list