问题
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.
I have customized setup.txt and constants.txt files inside the Configuration/TypoScript directory.
I also created custom directories for templates and partials inside the fileadmin directory: fileadmin/templates/ext/news/templates/ fileadmin/templates/ext/news/partials/
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/
}
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
回答1:
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.
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.
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!
来源:https://stackoverflow.com/questions/41874809/typo3-properly-edit-extension-template