【问题标题】:Typo3 Fluid Templates - How to set up different templates for different pagesTypo3 Fluid Templates - 如何为不同的页面设置不同的模板
【发布时间】:2019-11-13 05:50:19
【问题描述】:

我正在尝试使用typo3 9.5 从头开始​​构建一个网站,并为不同的页面设置不同的模板文件。我如何做到这一点?

我正在关注https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/TypoScriptConfiguration/Index.html 的教程,并尝试了Typo3 Fluid Templates How to add multiple templates 提供的解决方案,但没有成功

现在所有页面都加载默认模板,如果我将默认 cObject 设置为 Alternative,它会将 Alternative.html 加载到所有页面,即使 Typo3 的 TCA 已为每个页面正确设置:

  • 所有页面后端布局为[默认]
  • 联系人设置为 [Alternative]。

_

page = PAGE
page {
   typeNum = 0

   // Part 1: Fluid template section
   10 = FLUIDTEMPLATE
   10 {
      templateName = TEXT
      templateName.stdWrap.cObject = CASE
      templateName.stdWrap.cObject {
        key.data = pagelayout

        pagets__default = TEXT
        pagets__default.value = Default

        default = TEXT
        default.value = Default

        pagets__alternative = TEXT
        pagets__alternative.value = Alternative

        alternative = TEXT
        alternative.value = Alternative

      }


      templateRootPaths {
         0 = EXT:photo/Resources/Private/Templates/Page/
         1 = {$page.fluidtemplate.templateRootPath}
      }
      partialRootPaths {
         0 = EXT:photo/Resources/Private/Partials/Page/
         1 = {$page.fluidtemplate.partialRootPath}
      }
      layoutRootPaths {
         0 = EXT:photo/Resources/Private/Layouts/Page/
         1 = {$page.fluidtemplate.layoutRootPath}
      }
      dataProcessing {
      10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
      10 {
         levels = 1
         includeSpacer = 1
         as = mainnavigation
         }
      }
   }

我想为除联系页面之外的所有页面使用例如 default.html 模板,该页面将拥有自己的模板 ( site_template/Resources/Private/Templates/Page/Alternative.html )。

【问题讨论】:

  • 那么您为什么不创建两个部分,一个用于所有其他页面,一个仅用于联系人,然后在您的 default.html 上获取 uid 并加载您需要的部分的条件?
  • 您的建议不允许我使用不同的后端布局并更改整个页面结构,例如菜单或页脚。在typo3 6.2中,我曾经构建过这样的页面。
  • 为什么不呢?你可以使用任何你想要的布局。在部分上,您只需将 col pos 定义到必须保存数据的位置。您实际上可以定义您想要的布局,因此页脚或页眉也会有所不同......
  • 所以你是在告诉我像使用模板一样使用部分?嗯,这将是一个快速的解决方案。但是,我仍然对学习如何使用模板感兴趣。我不同意只知道一种解决方法。根据旧版本的typo3,我对文档感到非常困惑,我所做的一切都非常不同。无论如何感谢您的想法,很高兴知道!

标签: typo3 typoscript fluid typo3-9.x


【解决方案1】:

第一
您应该为模板的路径使用更大的数字。
数字越大,覆盖同名文件的优先级越高。

第二
没有字段pagelayout。使用layout 或更好的backend_layoutbackend_layout_next_levelexample configuration 充分使用子页面的配置)。

您的键值(pagets__defaultpagets__alternative)已经暗示了 backend_layout 的使用(pagets__* 是页面 TSconfig 中定义的后端布局的常用键)。

可能文档中的示例需要一些更正。 (拉取请求已提交)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-25
  • 2015-07-08
  • 1970-01-01
  • 1970-01-01
  • 2016-12-23
  • 2016-07-23
  • 1970-01-01
相关资源
最近更新 更多