开发者

TYPO3 / TypoScript: How to make a fallback?

I want to output a string to the rendered HTML by using two fallbacks.

My typoscript is defined at the top level page (root page of my website) and is passed to all pages at lower levels.

Structure:

  • Homepage
    • Page at level 1
      • Page at level 2

Regular output of the file:

The string comes from a TemplaVoila field (Page / Edit / Extended / MyField): field_copyright_name

To output it to the desired point in the HTML output a templaVoila mapping exists (Type: Typoscript Object Path), named: lib.copyright_name

The following typoscript does the job:

lib.hint_copyright_name = COA
lib.hint_copyright_name.10 = TEXT
lib.hint_copyright_name.10 {
    setCurrent.dataWrap = {field:field_copyright_name}
    current = 1
}

This works for all pages at all levels where the field (in page properties) is not empty.

The first fallback:

If the field is empty (in properties of that page, e.g. at level 2) typoscript should get the value from the pages above (at level 1, and if it is empty too, it should get it from homepage). No clue how to do it. Can you help?

The second fallback

If the first fallback still returns an empty string (because the field was empty at all levels) it should do a fallback t开发者_运维知识库o a default value "Copyright by me".

To enable this fallback without "first fallback" is easy:

switchdefault_copyright_name = TEXT
switchdefault_copyright_name {
    setCurrent.dataWrap = {field:field_copyright_name}
    current = 1
    override = "Copyright by me"
    override.if.isFalse.field = field_copyright_name
}


lib.hint_copyright_name = COA
lib.hint_copyright_name.10 < switchdefault_copyright_name

But how to integrate the "first fallback"?

EDIT:

I tried:

setCurrent.data = {levelfield:-1, field_copyright_name, slide}

or

setCurrent.data = levelfield:-1, field_copyright_name, slide

or

setCurrent.dataWrap = {levelfield:-1, field_copyright_name, slide}

or

setCurrent.dataWrap = levelfield:-1, field_copyright_name, slide

but without success - no output.


Just found this : http://lists.typo3.org/pipermail/typo3-english/2006-October/032764.html

It's supposed to make youre slide thing to work. Just set : Installation > all configuration > addRootLineFields

Didn't tried it, but seems like the solution

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜