【问题标题】:Render content elements from records field in a fluid template?从流体模板中的记录字段呈现内容元素?
【发布时间】:2019-10-18 02:47:00
【问题描述】:

我有一个使用记录字段的自定义内容元素。如何将此字段中的记录放入我的流体模板中?

我试过这样做:

ext_example < lib.contentElement
ext_example {
    templateName = MyTemplate
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\SplitProcessor
        10 {
          fieldName = records
          delimiter = ,
        }
    }
}

但它给出了一个这样的数组:'tt_content_26,tt_content_30' 如何删除前缀 tt_content_ 以便我有一个可以使用的 uid 数组?

【问题讨论】:

    标签: typo3 typoscript fluid typo3-9.x fluid-styled-content


    【解决方案1】:

    默认情况下,记录字段仅允许“tt_content”记录。因此,您在此字段中有一个 tt_content 记录的 UID 列表,但您在 pidInList 中使用这些 UID

    【讨论】:

    • 如果 UID 前面有类型前缀,则记录字段配置为允许不同类型的记录。在这种情况下,很难在查询中使用记录字段的值 - 因为您不知道是否只有预期类型的​​ UID。如果您真的确定该值,则可以使用 stdWrap 函数(例如替换)
    • 那么如果记录给我tt_content_1,tt_content_2,tt_content_3 我如何使用 SplitProcessor 替换来获取数字?
    • 通过使用 SplitProcessor,您无法修改/操作您的输入值。它仅拆分给定字段名称的值。使用 DatabaseQueryProcessor 是一个更好的解决方案。 uidInList { field = records stdWrap.replacement { 10 { search = tt_content_ replace = } } }
    猜你喜欢
    • 2015-10-27
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多