【问题标题】:Add a static template to my typo3 extension将静态模板添加到我的typo3 扩展
【发布时间】:2021-03-24 16:34:13
【问题描述】:

我已经使用 sitepackagebuilder.com 创建了一个扩展,这个想法只是编写一些静态 html。 我知道当你有一个控制器时,你可以按照约定名称调用模板。但是,如果您没有控制器怎么办?至少现在我需要的只是安装扩展,将插件添加到页面中并在该页面中获取一些静态内容。 我可以想象这是在一个打字稿文件中设置的,但我对所有打字稿的东西都很陌生。

我收到此错误: '在 TypoScript 对象路径“tt_content.list.20.heboorganigram_organigram”中找不到内容对象定义'

直到我在我的打字稿文件中定义了那个对象。这个我试过了。

tt_content.list.20.heboorganigram_organigram = PAGE
tt_content.list.20.heboorganigram_organigram.10 = TEMPLATE //(or FLUIDTEMPLATE same result)
tt_content.list.20.heboorganigram_organigram.10.template = FILE
tt_content.list.20.heboorganigram_organigram.10.template.file = fileadmin/Organigram.html

然后我没有收到错误,但我也没有从我的 Organigram.html 中获取内容,这只是尝试的东西,我实际上不知道这是否是我需要做的。

【问题讨论】:

  • "但是如果你没有控制器怎么办?" 只需创建它,它是无价的。

标签: typo3 typoscript fluid


【解决方案1】:

在创建新的内容元素之前,您首先必须创建页面模板,为此请查看站点包教程https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/FluidTemplates/Index.html

如果您已经获得页面模板,请查看https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html

如果你已经完成了上述步骤,为了获得你感兴趣的前端输出步骤Configure the frontend rendering

所以 TypoScript 应该看起来像这样:

lib.contentElement {
    templateRootPaths.200 = EXT:heboorganigram/Resources/Private/Templates/
}
tt_content {
    examples_newcontentelement =< lib.contentElement
    examples_newcontentelement {
        templateName = NewContentElement
    }
}

然后您需要将 Organigram.html 文件放在站点包内的​​ Templates 文件夹中。

【讨论】:

  • 嘿伙计,谢谢。是的,我现在明白了,我需要创建一个自定义内容元素,这是有道理的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-25
相关资源
最近更新 更多