Bug #29303

TYPO3\Fluid\View\TemplateView getTemplateRootPath should be public

Added by Fernando Arconada over 9 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
View
Target version:
-
Start date:
2011-08-28
Due date:
% Done:

100%

Estimated time:
Has patch:
No

Description

if TYPO3\Fluid\View\TemplateView setTemplateRootPath is public then the getTemplateRootPath should be also

The opposite have sense: set as protected and get as public. But if you could write you should be able to read what you have write

#1

Updated by Thomas Allmer about 9 years ago

I would totally agree to this as if you define the complete path to the template you loose the ability to configure/change it so you would have to create a separate setting which is not very nice usability wise.
If this function gets public you can use it to make it depending on the TemplateRootPath and people are used to change it if needed.

$view = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView');
// $view->setTemplatePathAndFilename('typo3conf/ext/xform/Resources/Private/Templates/Email/TipAFriend.html');
$view->setTemplatePathAndFilename($this->view->getTemplateRootPath() . 'Email/TipAFriend.html');
$body = $view->render();
#2

Updated by Bastian Waidelich about 9 years ago

  • Category set to View

Thomas Allmer wrote:

In your example $this->view->getTemplateRootPath() would be NULL as you didn't specify a path.

#3

Updated by Bastian Waidelich about 9 years ago

Fernando Arconada wrote:

if TYPO3\Fluid\View\TemplateView setTemplateRootPath is public then
the getTemplateRootPath should be also

Hi Fernando,

I agree, that this makes sense in general! We just have to keep this in sync with FLOW3, so please bear with us. In the meantime you could work around this like that:

$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = $extbaseFrameworkConfiguration['view']['templateRootPath'];

#4

Updated by Thomas Allmer about 9 years ago

Bastian Waidelich wrote:

In your example $this->view->getTemplateRootPath() would be NULL as you didn't specify a path.

no it's the root path of the current view... (which is the value from plugin.tx_ext.view.templateRootPath)
$view != $this->view

your workaround certainly works, but it certainly looks like one :p
$this->view->getTemplateRootPath() seems nicer... what do you think? at some point possible or should I drop the idea and always use the "workaround"

#5

Updated by Bastian Waidelich about 9 years ago

Thomas Allmer wrote:

Bastian Waidelich wrote:

In your example $this->view->getTemplateRootPath() would be NULL as you didn't specify a path.

no it's the root path of the current view...
(which is the value from plugin.tx_ext.view.templateRootPath)

In this case you used a Tx_Fluid_View_StandaloneView and that won't know anything about your TS configuration.

your workaround certainly works, but it certainly looks like one :p
$this->view->getTemplateRootPath() seems nicer... what do you think?
at some point possible or should I drop the idea and always use the "workaround"

The thing is: It is already a work around if you need to change the template in an action. I would be interested in a realistic use case here. Having said that, I do think that View variants make sense sometimes. They might make it into the core sometimes. Until then it's just a matter of a few lines to integrate this (see http://forge.typo3.org/projects/typo3v4-mvc/wiki/How_to_change_the_template_for_one_plugin_instance) in your extension. And this looks much less like a work around IMO.
But, still, it might make sense to make getTemplateRootPath() public ;)

#6

Updated by Bastian Waidelich about 9 years ago

Bastian Waidelich wrote:

no it's the root path of the current view...
(which is the value from plugin.tx_ext.view.templateRootPath)

In this case you used a Tx_Fluid_View_StandaloneView and that won't know anything about your TS configuration.

I overlooked the $this-> in your example.

And, you're right, for template based emails you have to deal with the template path obviously (see example solution at http://forge.typo3.org/projects/typo3v4-mvc/wiki/How_to_use_the_Fluid_Standalone_view_to_render_template_based_emails)

#8

Updated by Gerrit Code Review about 8 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16440

#9

Updated by Gerrit Code Review over 7 years ago

Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/19047

#10

Updated by Gerrit Code Review over 7 years ago

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at https://review.typo3.org/19048

#11

Updated by Adrian Föder over 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF