[TYPO3-english] COA inside another COA - is it a wise thing?

JoH asenau info at cybercraft.de
Tue May 11 14:24:40 CEST 2010


Jigal van Hemert wrote:
> JoH asenau wrote:
>> please answer the questions - How would you do this without COA?
>> What is unstructured and not easy to understand about it?
>>
>> myElement = COA
>> myElement {
>>     wrap = <div class="container">|</div>
>>     10 = TEXT
>>     10 {
>>         value = blah
>>         wrap = <h1>|</h1>
>>     }
>>     20 = COA
>>     20 {
>>         wrap = <div class="text image">|</div>
>>         10 = TEXT
>>         10.value = blah
>>         10.wrap = <p>|</p>
>>         20 = IMAGE
>>         20.file = blah
>>     }
>> }
>
> Joey,
>
> When you look closely to this example there is only static stuff. The
> only thing which needs procession is the IMAGE object. So the
> minimalistic version could be:
>
> myElement = IMAGE
> myElement {
> file = blah
> wrap = <div class="container"><h1>blah</h1><div class="text
> image"><p>blah</p>|</div>
> }
>
> The whole exercise with the COAs, values, wraps, etc. does not add
> anything to the functionality and only uses various resources.
>
> But of course you meant that all the 'blah' parts would be external
> data, etc.; I think this is what Dmitry meant by "too generic".
> The only time I would produce the complicated variation is in case of
> a demo version where the dynamic data isn't there yet..

I would always prefer the solution with the COAs no matter if there will be
external data or not, because with the "simple" approach you'll be stuck,
when you want to add something before, after or - even worse - in between
the various parts. Especially when it comes to conditions or other stuff
that might change the behaviour of the TypoScript, it will pay off.

In my case you can easily do something like that:

[loginUser = *]
myElement {
  15 = TEXT
  15 {
    value = You see this because you are logged in
    wrap = <h2>|</h2>
  }
}
[global]

or

[loginUser = *]
myElement {
  20 >
  20 = TEXT
  20 {
    value = Available for logged in users only
    wrap = <p class="alert">|</p>
  }
}
[global]

In the "easy" case you will have to rewrite the whole stuff. This might
still be easy for the "generic" example, but will introduce a huge overhead,
when stuff is getting more complex.

So my advice is: Use COA to give your TS more structure and make it easer to
maintain.

HTH

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com




More information about the TYPO3-english mailing list