[TYPO3-english] TypoScript: conditional wrap question

JoH asenau info at cybercraft.de
Mon Sep 28 15:13:50 CEST 2009


> Hat's off to you!

Thx :-)

> Your solution worked without revisions other than the 10 index key.
> It's nice and clean and even more fully demonstrates the power of
> TypoScript if conditions than I had thought out.

IMHO the most important thing it demonstrates is that stdWrap functions are
executed in a certain order (regardless of their order in the TS template,
which is the correct one in the example but could be changed without
changing the result). This is why i.e. "dataWrap" would not give the same
results here, but the following code still would do the job:

10 = TEXT
10 {
    ifEmpty.data = page:author_email
    postCObject = TEXT
    postCObject {
        noTrimWrap = | (|)|
        data = page:author_email
        required = 1
        if.isTrue.data = page:author
    }
    wrap = <meta name="author" content="|" />
    required = 1
    data = page:author
}

First there will be "data" followed by "ifEmpty", which will work for the
cases having only one of the fields set.
Then "required" will check for any kind of content and prevent the rest from
being executed, if there is no content available at all.
After that "postCObject" is appended ("append" won't be working since it
comes _after_ "wrap"), but only if the author field has been used before.
Finally the content will be wrapped.

Replacing "postCObject" with "append" would require "wrap" to be replaced
with "wrap3" or "outerWrap" as well to keep the order intact. Taking a look
at this section of TSref
http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4149585
might help to determine the correct stdWrap functions for a certain order,
since they will be excuted exactly in the order that can be found in the
documentation.

BTW: As a side effect this demonstrates that there is a reason why we got
more than one "wrap" in TypoScript and why we should keep it like that.

Cheers

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
TYPO3 workshops: http://workshops.eqony.com




More information about the TYPO3-english mailing list