Commit 0f63cfc6 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Actually make the fluid template configurable like the readme says

parent 2edcc34a
......@@ -100,7 +100,7 @@ class PluginController extends AbstractPlugin {
$renderer->addInlineJavaScriptCode($records, $this->pluginConfiguration['mode'], $tabId);
} else if ($this->pluginConfiguration['renderer'] === 'Fluid') {
/** @var $renderer FluidView */
$renderer = GeneralUtility::makeInstance(FluidView::class);
$renderer = GeneralUtility::makeInstance(FluidView::class, $this->pluginConfiguration);
}
return $renderer;
......
......@@ -33,6 +33,31 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*/
class FluidView implements SingletonInterface {
/**
* @var array
*/
protected $settings = [
'templateRootPaths' => ['EXT:df_tabs/Resources/Private/Templates/'],
'partialRootPaths' => ['EXT:df_tabs/Resources/Private/Partials/'],
'layoutRootPaths' => ['EXT:df_tabs/Resources/Private/Layouts/']
];
/**
* FluidView constructor.
* @param array $settings
*/
public function __construct(array $settings = []) {
if (!empty($settings['view.']['templateRootPaths.'])) {
$this->settings['templateRootPaths'] = $settings['view.']['templateRootPaths.'];
}
if (!empty($settings['view.']['partialRootPaths.'])) {
$this->settings['partialRootPaths'] = $settings['view.']['partialRootPaths.'];
}
if (!empty($settings['view.']['layoutRootPaths.'])) {
$this->settings['layoutRootPaths'] = $settings['view.']['layoutRootPaths.'];
}
}
/**
* Renders the tabs
*
......@@ -42,11 +67,14 @@ class FluidView implements SingletonInterface {
*/
public function renderTabs($tabElements, $tabId) {
$fluidView = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$fluidView->setTemplateRootPaths([
GeneralUtility::getFileAbsFileName('EXT:df_tabs/Resources/Private/Templates')
$fluidView->setTemplateRootPaths($this->settings['templateRootPaths']);
$fluidView->setPartialRootPaths($this->settings['partialRootPaths']);
$fluidView->setLayoutRootPaths($this->settings['layoutRootPaths']);
$fluidView->setTemplate('Standard/Tabs.html');
$fluidView->assignMultiple([
'tabElements' => $tabElements,
'tabId' => $tabId
]);
$fluidView->setTemplate('Tabs.html');
$fluidView->assign('tabElements', $tabElements);
return $fluidView->render();
}
......
......@@ -7,6 +7,13 @@ plugin.tx_dftabs_plugin1 {
# cat=plugin.tx_dftabs_plugin1/settings; type=text; label=Defines the Renderer that is used
renderer = TypoScript
# Fluid settings
view {
templateRootPath = EXT:df_tabs/Resources/Private/Templates/
partialRootPath = EXT:df_tabs/Resources/Private/Partials/
layoutRootPath = EXT:df_tabs/Resources/Private/Layouts/
}
# typoscript specific options
enableJavascript = 1
defaultTabTitle = Tab
......
......@@ -32,6 +32,19 @@ plugin.tx_dftabs_plugin1 {
tt_content = {$plugin.tx_dftabs_plugin1.tt_content}
renderer = {$plugin.tx_dftabs_plugin1.renderer}
# Fluid view settings
view {
templateRootPaths {
10 = {$plugin.tx_dftabs_plugin1.view.templateRootPath}
}
partialRootPaths {
10 = {$plugin.tx_dftabs_plugin1.view.partialRootPath}
}
layoutRootPaths {
10 = {$plugin.tx_dftabs_plugin1.view.layoutRootPath}
}
}
# javascript events
events {
onBeforeInitialize = function() {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment