简体   繁体   English

TYPO3 / TypoScript:如何进行后备?

[英]TYPO3 / TypoScript: How to make a fallback?

I want to output a string to the rendered HTML by using two fallbacks.我想通过使用两个后备将 output 一个字符串传递给呈现的 HTML 。

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第 1 层的页面
      • Page at level 2第 2 级页面

Regular output of the file:文件的常规 output:

The string comes from a TemplaVoila field (Page / Edit / Extended / MyField): field_copyright_name该字符串来自 TemplaVoila 字段(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 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, eg 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).如果该字段为空(在该页面的属性中,例如在第 2 级),打字稿应该从上面的页面中获取值(在第 1 级,如果它也是空的,它应该从主页中获取)。 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 to 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.但没有成功 - 没有 output。

Just found this: http://lists.typo3.org/pipermail/typo3-english/2006-October/032764.html刚刚发现这个: http://lists.typo3.org/pipermail/typo3-english/2006-October/032764.ZFC35FDC70D5FC69A769883A82EC

It's supposed to make youre slide thing to work.它应该让你的幻灯片工作。 Just set: Installation > all configuration > addRootLineFields只需设置:安装 > 所有配置 > addRootLineFields

Didn't tried it, but seems like the solution没试过,但似乎是解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM