[TYPO3-mvc] TypoScript manipulation per object property

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Jul 23 02:05:54 CEST 2010


Hi Helmut,

>> Don't know if proxy is the correct wording for it - maybe call it
>> "wrapper" class. Basically you create a class/object with magic getters
>> and assign your object/array to it as well as the basic TS path it
>> should use to check for TS definitions. Then you assign this "wrapper"
>> object to your view (maybe with a slight different naming). Now, use
>> this object just like your other object in the template.
>
> This pattern is known as "decorator pattern".

Thanks, that really fits :)

> What about having something like this:
>
> $view->assign('myobject',$myobject,'Tx_Fluid_View_PropertyDecorator');
>
> (Third parameter optional)

I don't like having that logic in the controller. What if one likes to 
use a decorator in a view of a foreign extension? So this should really 
be moved to the view I think.

> I would like the approach, but it somehow conflicts the
> (format-)viewhelper idea.

how about f:format.decorate ;) I know that this conflicts with the 
overall idea of viewHelpers that should be used to format content - but 
having TS processing easily available for all properties of a object is 
just to handy. Basic formatting should of course still be done in the 
template and via dedicated viewHelpers.


<f:format.decorate use="{myObject}" as="decoratedObject" 
using="plugin.tx_myext.decorations">
{decoratedObject.title}
{decoratedObject.description}
</f:format.decorate>

or

<f:decorator using="plugin.tx_myext.decorations">
{myObject.title -> f:format.decorate(key:'title')}
{myObject.description -> f:format.decorate(key:'description')}
</f:decorator>
-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list