TYPO3 - 正确编辑扩展模板 [英] TYPO3 - properly edit extension template

查看:22
本文介绍了TYPO3 - 正确编辑扩展模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TYPO3 7.6.13 并且我正在尝试自定义新闻扩展.我正在尝试插入我自己的自定义模板,但 TYPO3 找不到它,因此始终包含默认模板.

I am using TYPO3 7.6.13 and I am trying to customize news extension. I am trying to insert my own custom template but TYPO3 can't find it, therefore default template is always included.

我在 Configuration/TypoScript 目录中自定义了 setup.txt 和 constants.txt 文件.

I have customized setup.txt and constants.txt files inside the Configuration/TypoScript directory.

我还在 fileadmin 目录中为模板和部分创建了自定义目录:文件管理/模板/分机/新闻/模板/fileadmin/templates/ext/news/partials/

I also created custom directories for templates and partials inside the fileadmin directory: fileadmin/templates/ext/news/templates/ fileadmin/templates/ext/news/partials/

这是 setup.txt 的一部分:

This is part of setup.txt:

plugin.tx_news {
    mvc.callDefaultActionIfActionCantBeResolved = 1
    view {
        templateRootPaths {
            0 = EXT:news/Resources/Private/Templates/
            1 = {$plugin.tx_news.view.templateRootPath}

        }
        partialRootPaths {
            0 = EXT:news/Resources/Private/Partials
            1 = {$plugin.tx_news.view.partialRootPath}

        }
        layoutRootPaths {
            0 = EXT:news/Resources/Private/Layouts/
            1 = {$plugin.tx_news.view.layoutRootPath}
        }
widget.GeorgRinger\News\ViewHelpers\Widget\PaginateViewHelper.templateRootPath = EXT:news/Resources/Private/Templates/
    }

我已将我在 fileadmin 中创建的模板和部分的自定义目录添加到 constants.txt 中.下面是constants.txt代码:

I have added into constants.txt custom directories for templates and partials that I created inside of fileadmin. Below is constants.txt code:

plugin.tx_news {
rss.channel {
    title = Dummy Title
    description =
    link = http://example.com
    language = en-gb
    copyright = TYPO3 News
    category =
    generator = TYPO3 EXT:news
}

opengraph {
    site_name =

    twitter {
        card = summary
        site =
        creator =
    }
}

view {
    # cat=plugin.tx_news/file; type=string; label=Path to template root (FE)
    templateRootPath = fileadmin/templates/ext/news/templates/
    #templateRootPath.1 = EXT:news/Resources/Private/Templates/
    # cat=plugin.tx_news/file; type=string; label=Path to template partials (FE)
    partialRootPath = fileadmin/templates/ext/news/partials/
    #partialRootPath.2 = EXT:news/Resources/Private/Partials/
    # cat=plugin.tx_news/file; type=string; label=Path to template layouts (FE)
    layoutRootPath = EXT:news/Resources/Private/Layouts/
}

settings {
    # cat=plugin.tx_news/file; type=string; label=Path to CSS file
    cssFile = EXT:news/Resources/Public/Css/news-basic.css
}

}

非常感谢任何帮助!丹尼斯

Any help is greatly appreciated! Denis

推荐答案

不要在模板定义中混淆 templateRootPathtemplateRootPaths (+partial + layout) 路径!如果名称和用法像在常量文件中一样混淆,请小心(在注释中,数组项定义为单数形式!但因为它们是无关紧要的注释)

Don't mix up templateRootPath and templateRootPaths in the definition for the template (+partial + layout) pathes! be careful if the names and usages mix up like in the constant file (in the comments there are array items defined to the singular form! but as they are comments that does not matter)

并且永远不要修改您不是作者的任何扩展名中的任何文件.

And never ever modify any files from any extension you are not author of.

如果这些行来自 ext:news 的静态模板文件,您可以构建自己的排版模板(即使从文件中包含),但将其包含在扩展静态之后(或在模板记录中包含静态).

If those lines are from the static template files from ext:news, you can build an own typoscript template (even as include from files) but include it after the extension statics (or include the statics in your template record).

您需要扩展静态,因为它们定义了一般配置.

you need the extension statics as they define the general configuration.

然后您可以使用常量编辑器在您的排版模板中输入您的值,以便在扩展的静态模板中设置.

then you might use the constant editor to enter your values in your typoscript template to be set in the static template of the extension.

现在你有了一个清晰的定义,你的值应该被使用并且扩展应该可以工作.

now you have a clean definition and your values should be used and the extension should work.

否则,您可以从 TS 设置中的扩展设置 TS.特别是如果您想设置常量编辑器中不可用的值.因此,您需要知道从扩展中评估哪些值.看看手册!

otherwise you can set the TS from an extension in your TS setup. especially if you want to set values not avaliable in the constant editor. therefore you need to know which values are evaluated from the extension. have a look into the manual!

这篇关于TYPO3 - 正确编辑扩展模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆