[TYPO3-english] TypoScript: conditional wrap question
Thorsten Kahler [dkd]
thorsten.kahler at dkd.de
Sat Sep 26 15:52:17 CEST 2009
Hi Michael,
Michael Cannon schrieb am 26.09.2009 11:42 Uhr:
> The TypoScript below works as desired, but I feel there's a simpler way.
>
>
> Output
>
> no page author or page email, then no tag
>
> page author only exists
> <meta name="author" content="Michael Cannon" />
>
> page email only exists
> <meta name="author" content="mc at acqal.com" />
>
> both page author or page email exists
> <meta name="author" content="Michael Cannon (mc at acqal.com)" />
because there are four options to consider, a CASE object seems like the
perfect solution to me. Let's try:
8<--
80 = CASE
80 {
key.cObject = COA
key.cObject {
# set the author flag
10 = TEXT
10.value = a
10.fieldRequired = author
# set the email flag
20 = TEXT
20.value = e
20.fieldRequired = author_email
}
# default: do nothing
# default = NOOP
# only author
a = TEXT
a.field = author
e = TEXT
e.field = author_email
ae = TEXT
ae.dataWrap = {field:author} ({field:author_email})
stdWrap {
required = 1
wrap = <meta name="author" content=" | " />
}
}
-->8
I first thought about using a bitmap as key value, but "a" and "e" IMHO
provide more information to the reader. So in the end this version is
not really simpler, but at least more readable.
Best regards
Thorsten
--
Thorsten Kahler
thorsten.kahler at dkd.de
More information about the TYPO3-english
mailing list