通过“插入记录”插入TYPO3 8.7

时间:2018-10-24 15:45:02

标签: typo3 fluid typo3-8.x

我正在寻找一种显示在TYPO3 8.7 LTS中插入了“插入记录”内容元素的tt_address元素的方法。我知道css_styled_content的一种方法,但我不知道如何使用fluid_styled_content做到这一点。 Slack上的某人将我指向“ RECORDS” TS对象,也许是DatabaseQueryProcessor。可悲的是,我找不到适合我的用例的教程或文档。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

有两种方法

tt_address的自定义内容元素

那是正确的方法。

您可以检查TYPO3本身如何在“快捷方式”内容元素(从编辑器的角度来看为“插入记录”)中。

这些提示完全有效。使用FLUIDTEMPLATE定义要呈现的模板,并按照以下文档中的说明添加DatabaseQueryProcessor:https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html#dataprocessing

可以在源代码https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-7/typo3/sysext/frontend/Classes/DataProcessing/DatabaseQueryProcessor.php#L22中找到处理器,并在PHPDoc中使用示例配置进行配置,该文件已使用tt_address。

以下是内容元素的完整TypoScript示例:

tt_content.custom_content =< lib.contentElement
tt_content.custom_content {
    templateName = TtAddressRecords
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        10 {
            table = tt_address
            pidInList = 123
            as = addresses
        }
    }
}

使用现有的快捷方式内容元素

如果您已经在使用本机快捷方式内容元素,则可以使用某些配置立即使用。它将解决选定的记录。

首先,您必须允许通过此元素呈现tt_address记录。因此,将以下内容添加到TypoScript常量中:

styles {
    content {
        shortcut {
            tables := addToList(tt_address)
        }
    }
}

这会将tt_address添加到现有的tt_content表中。

接下来,您需要tt_address记录的呈现定义。这是在TypoScript安装程序中完成的。例如。将以下TypoScript添加到设置中,并根据需要调整路径:

tt_address < lib.contentElement
tt_address {
    templateName = TtAddress
    templateRootPaths {
        10 = EXT:cdx_site/Resources/Private/Templates/Plugins/
    }
}

上面的示例将使用“流体模板” cdx_site / Resources / Private / Templates / Plugins / TtAddress.html 呈现每个tt_address记录。

应该不需要调整Shortcut.html模板,因为它只会显示呈现的记录。

相关问题