Andere Templates für Actions
setCustomPathsInView
Um andere Templates für Actions zu verwenden muss man in der Klasse Tx_Rsysproductbase_Controller_AbstractController die folgende Methode einfügen:
/**
* Set the TS defined custom paths in view
*
* @param Tx_Extbase_MVC_View_ViewInterface $view
* @throws Exception
*/
protected function setCustomPathsInView(Tx_Extbase_MVC_View_ViewInterface $view) {
// overwrite a template via TS using plugin.EXTNAME.settings.controller.<ControllerName>.<actionName>.template
$templatePathAndFilename = $this->settings['controller'][$this->request->getControllerName()][$this->request->getControllerActionName()]['template'];
if(!empty($templatePathAndFilename)) {
if (file_exists(t3lib_div::getFileAbsFileName($templatePathAndFilename))) {
$view->setTemplatePathAndFilename(t3lib_div::getFileAbsFileName($templatePathAndFilename));
} else {
throw new Exception('Given template path and filename could not be found or resolved: ' . $templatePathAndFilename . ' 1284655109');
}
}
}
Aufgerufen wird sie in der initializeView Methode:
/**
* Initializes the view before invoking an action method.
*
* Override this method to solve assign variables common for all actions
* or prepare the view in another way before the action is called.
*
* @param Tx_Extbase_View_ViewInterface $view The view to be initialized
* @return void
* @api
*/
protected function initializeView(Tx_Extbase_MVC_View_ViewInterface $view) {
$this->setCustomPathsInView($view);
}
Dann kann man pro Seite ein abweichendes Template konfigurieren mit TS:
plugin.tx_rsysproductbase {
controller {
Product {
index.template = typo3conf/ext/rsysproductbase/Resources/Private/Templates/Category/IndexVariante.html
}
}
}