[TYPO3-dev] Array as data in TS
Christian Opitz - Netzelf
christian.opitz at netzelf.de
Tue Jan 12 11:25:14 CET 2010
Christopher Torgalson schrieb:
> 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]
>
Ah okay - thank you. The way with .split seems to get a bit more
complicated when the arrays contain more fields than just title in the
example above and i want to output them.
I'll try the solution with HMENU and post about it if it works.
Thanks and cheers,
Christian
More information about the TYPO3-dev
mailing list