[TYPO3-english] replace only one template, not the whole path
Krystian Szymukowicz
k.szymukowicz at gmail.com
Fri Nov 29 17:59:14 CET 2013
W dniu 2013-11-28 17:15, Katja Lampela wrote:
> Hi,
>
> I'm working with tx_news and I'm trying to find a way to replace only
> the list.html template.
>
> I find only this ts reference to templates:
>
> plugin.tx_news.view.templateRootPath =
> EXT:news/Resources/Private/Templates/
>
> Does this mean I have to copy all the templates in this extension folder
> to my own folder even if I want to modify only this one html template?
>
> (Sorry if this is obvious, this is still new to me and I haven't found
> THE documentation for the new templating system)
>
>
hi
I use smth like this in the forked version of news:
In the Classes/BaseControlle.php I do:
protected function initializeView1(Tx_Extbase_MVC_View_ViewInterface
$view) {
// overwrite default template
$controller = $this->request->getControllerName();
$action = $this->request->getControllerActionName();
if ($controller && $action) {
if ($this->settings['Default']['default']['templateFile']) {
// overwrite from flexform
$templateFile = $this->settings['Default']['default']['templateFile'];
} else {
// overwrite from typoscript
$templateFile = $this->settings[$controller][$action]['templateFile'];
}
$templateFile = t3lib_div::getFileAbsFileName($templateFile);
if (file_exists($templateFile) && $templateFile) {
$this->view->setTemplatePathAndFilename($templateFile);
}
}
}
then in flexform I add:
<settings.Default.default.templateFile>
<TCEforms>
<label>Template file (if empty the default
will be choosen)</label>
<config>
<type>group</type>
<internal_type>file</internal_type>
<allowed>tpl,html</allowed>
<max_size>500</max_size>
<uploadfolder></uploadfolder>
<minitems>0</minitems>
<maxitems>1</maxitems>
<size>1</size>
</config>
</TCEforms>
</settings.Default.default.templateFile>
This was I can use separate template in flexform but also have separate
template for each TS call like for example:
20 = USER
20 {
userFunc = tx_extbase_core_bootstrap->run
extensionName = Vcs
pluginName = Pi1
switchableControllerActions.Item.1 = list
settings {
featuredRestriction = nonFeatured
Item.list.templateFile =
{$plugin.tx_vcs.view.templateRootPath}Item/MenuSidebarNonFeatured.html
}
20 = USER
20 {
userFunc = tx_extbase_core_bootstrap->run
extensionName = Vcs
pluginName = Pi1
switchableControllerActions.Item.1 = list
settings {
featuredRestriction = featured
Item.list.templateFile =
{$plugin.tx_vcs.view.templateRootPath}Item/MenuSidebarFeatured.html
}
This way I can use the power of demaned object and prevent from having
lot of actions like those building menu from record like
menuSidebarAction, menuFooterAction etc, etc.
All I need is a powerfull list action and lot of tempaltes.
--
grtz
Krystian Szymukowicz
More information about the TYPO3-english
mailing list