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

时间:2018-05-24 14:48:04

标签: typo3 tx-news

我正在为一本杂志的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底部添加了这些行,当然也没有自定义路径。

我感谢所有的帮助。

3 个答案:

答案 0 :(得分:2)

您错过了为您的模板版本声明的内容。

你有两种方式:

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

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

  3. 当您对所有配置使用页面扩展时,您将避免使用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,则可以使用更高的值来为模板提供更高的优先级 - 以防多个扩展和模板替换处于活动状态。

    这会为您要覆盖的布局,部分和模板配置pathes:

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

    在你的扩展程序中。

    请勿使用问题中的TS (即使它来自原始手册。)
    它删除预定义的pathes。 (第3,8,13行)。在内部修补程序发生更改的更新后,这可能会失败。

答案 1 :(得分:0)

  • 仅复制EXT中的模板:扩展程序中的新闻 想要改变。您的示例TypoScript用作后备,并且在0中搜索错过的模板。

  • 仅覆盖您要更改的TypoScript。

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

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

答案 2 :(得分:-1)

把它放在你的常数上:

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

或在您的设置上执行此操作:

plugin.tx_news {
   view {
    templateRootPaths = fileadmin/templates/ext/news/Templates/
    partialRootPaths = fileadmin/templates/ext/news/Partials/
    layoutRootPaths = fileadmin/templates/ext/news/Layouts/
  }
}

然后在您所属的文件夹中复制所需的新闻资源,并尝试在部分模板上将{newsItem.title}编辑为{newsItem.title} ahha。如果您在前端看到了标题,并且后面有ahha,则表示您现在可以按照自己的方式编辑流体模板。

祝你好运

相关问题