从另一个扩展覆盖流体模板

Override a Fluid Template from another extension

我正在为一本杂志制作 TYPO3 网页。因此我使用扩展名 "news" 或 "tx_news".

一切正常,只是我对如何以及在何处覆盖新闻扩展中给定的流体模板感到困惑。对于我使用自己的扩展程序来保存所有后端布局和流体模板的网页,我想在我的扩展程序中包括一个自己的新闻流体模板,这样我所做的更改就不会被覆盖当然更新新闻扩展。

我试过将动态模板从新闻复制粘贴到我的扩展程序中,希望它们被覆盖,因为我的扩展程序在后端具有最高优先级。我还在 documentation 上发现我应该将以下行添加到我的 TS 设置中:

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

我已经在我自己的扩展程序 setup.txt 的底部添加了这些行,当然还有自定义路径,但它也没有用。

感谢所有帮助。

  • 仅从 EXT:news 中复制模板 想改变。您的示例 TypoScript 用作后备,在 1 中丢失的模板在 0 中搜索。

  • 仅覆盖您要更改的 TypoScript。

  • 然后使用 TypoScript 对象浏览器并检查 TypoScript 设置 plugin.tx_news.view...

  • 如果您没有看到正确的路径,则 TypoScript 的加载顺序必须是 改变了。

您没有声明您的模板版本的路径。

你有两种方法:

  1. 使用常量ext:news为您提供并在TS设置中自动插入

  2. 直接在插件配置中添加一些行。

当您对所有配置使用页面扩展时,您将避免使用 TS 常量编辑器或仅使用它来识别常量的名称。

// Path constants from ext:news:
plugin.tx_news {
    view {
        layoutRootPath   = EXT:yourextension/Resources/Private/News/Layouts/
        partialRootPath  = EXT:yourextension/Resources/Private/News/Partials/
        templateRootPath = EXT:yourextension/Resources/Private/News/Templates/
    }
}

无论如何你应该得到这样的 TS(用 TSOB 检查):

plugin.tx_news {
    view {
        templateRootPaths {
            0 = EXT:news/Resources/Private/Templates/
            1 = EXT:yourextension/Resources/Private/News/Templates/
        }
        partialRootPaths {
            0 = EXT:news/Resources/Private/Partials/
            1 = EXT:yourextension/Resources/Private/News/Partials/
        }
        layoutRootPaths {
            0 = EXT:news/Resources/Private/Layouts/
            1 = EXT:yourextension/Resources/Private/News/Layouts/
        }
    }
}

如果您使用方法 2,您可以使用更高的值来为您的模板提供更高的优先级 - 以防多个扩展和模板替换处于活动状态。

这会配置您要覆盖的布局、部分和模板的路径:

Resources
  +- Private
      +- News
          +- Layouts
          +- Partials
          +- Templates

在您的分机中。

不要使用你问题中的 TS(即使它来自原始手册。)
它删除预定义的路径。 (第 3、8、13 行)。这可能会在内部路径发生更改的更新后失败。