【问题标题】:TYPO3 tx_news extension not using override templateTYPO3 tx_news 扩展不使用覆盖模板
【发布时间】:2016-10-17 21:09:41
【问题描述】:

我有两个使用 tx_news 扩展的网站。据我所知,它们的设置相同。在站点 A 上,我添加了一个新的 List.html 部分,它按预期工作。但是在站点 B 上,它完全忽略了我的列表覆盖。

我已经三次检查文件路径以确保打字稿指向正确的位置,但它仍然使用默认值。这里有什么问题?

plugin.tx_news {
  view {
    templateRootPaths >
    templateRootPaths {
      0 = EXT:news/Resources/Private/Templates/
      1 = fileadmin/templates/example/news/Templates/
    }
    partialRootPaths >
    partialRootPaths {
      0 = EXT:news/Resources/Private/Partials/
      1 = fileadmin/templates/example/news/Partials/
    }
    layoutRootPaths >
    layoutRootPaths {
      0 = EXT:news/Resources/Private/Layouts/
      1 = fileadmin/templates/example/news/Layouts/
    }
  }
}

【问题讨论】:

  • 如果您在模板设置中看到此行,请在 TypoScript 对象浏览器中检查 BE。
  • @AndrásOttó 检查对象浏览器显示我之前在设置脚本中缺少一个 }。重新添加它可以解决问题。简单的!做出一个答案,我会选择它。

标签: typo3 typoscript fluid typo3-7.6.x


【解决方案1】:

为了使其按预期工作,我将执行以下操作:

1) 将ext/news/Resources/Private/Templates、Partials、Layouts这三个文件夹复制到fileadmin/templates/example/news (我相信你已经这样做了)

2) 然后将其放入您的模板提供程序或页面typoscript constants

plugin.tx_news {
    view {
        templateRootPath = fileadmin/templates/example/news/Templates/
        partialRootPath = fileadmin/templates/example/news/Partials/
        layoutRootPath = fileadmin/templates/example/news/Layouts/
    }
}

现在新闻扩展将使用放在 fileadmin/ 中的模板文件

下一步是在您的根页面属性中添加一些 pageTSConfig,以防您需要更大的灵活性。比如这样:

tx_news.templateLayouts {
    1 = Special List Item
    2 = Special Detail Layout
}

这允许您在新闻插件中选择这些模板布局之一并在模板文件中使用条件:

<f:if condition="{settings.templateLayout} == 1">
    <f:then>
        <!-- markup for a special list item -->
    </f:then>
    <f:else>
        <!-- markup for another list item -->
    </f:else>
</f:if>

【讨论】:

  • 您不应再使用已弃用的templateRootPath 等,而应使用复数版本templateRootPaths
  • 如果你的意思是forge entry,我不知道。但是,它适用于我的 6.2.25 和 7.6.9 安装。
  • 实际上,在常量中你可以使用单数,因为它是一个常量,而在设置中你应该使用复数,因为这是处理带有后备的多个模板的逻辑。
【解决方案2】:

您的脚本看起来不错。当在 TYPO3 中发生类似情况时,可以选择检查您的 TypoScript 是否有效,或者此更改是否真正添加到正确的位置。

进入 BE,选择 Template 模块并使用 TypoScript Object Browser 您可以查看您的设置中是否有所有更改。 (或者如果你可能有语法错误)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 2018-01-05
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    相关资源
    最近更新 更多