[TYPO3-mvc] How to access typoscript properties in viewHelpers?

Daniel Dimitrov danielsd_bg at yahoo.fr
Tue May 18 11:15:17 CEST 2010


Slowly I'm starting to be really confused with this. Can someone explain me 
why don't we have a factory method to load the settings?
something like
$mySettings = TFactory::getTypoScriptSettings(); ?
remembering all the methods to access the settings is annoying.
controller : $this->settings
viewHelper = $this->templateVariableContainer('get')
repository = ????
model = ????

It is the same with the request object
controller = $this->request
viewHelper = $this->controllerContext->getRequest

Kind Regards,
Daniel

"Franz Koch" <typo3.RemoveForMessage at elements-net.de> wrote in message 
news:mailman.1.1273140034.10424.typo3-project-typo3v4mvc at lists.typo3.org...
> Hey,
>
>> I guess that the answer to my question is going to be super easy, but I
>> cannot figure it on my own for 1h now.
>> In controllers we can use $this->settings and we can get the properties
>> from our typoscript setup file.
>>
>> How to use Typoscript in my viewHelpers?
>> plugin.my_plugin {
>> settings {
>> itemsPerPage = 20
>> }
>> }
>>
>> I want to use this itemsPerPage in my controller and viewHelper. Any way
>> to do that?
>
> why don't you pass it to your viewHelper as argument/parameter?
>
> <xy:pagination itemsPerPage="{settings.itemsPerPage}" 
> itemsTotal="{f:count(subject:myObjects)}"/>
>
> But if you prefer to access your settings directly in your viewHelper, try 
> this:
> $settings = $this->templateVariableContainer->get('settings');
>
> I'm not sure if there is any easier/better solution - but it's working.
>
> -- 
> kind regards,
> Franz Koch 



More information about the TYPO3-project-typo3v4mvc mailing list