[TYPO3-mvc] Accessing fluids viewhelpers

Susanne Moog typo3 at susannemoog.de
Mon May 25 13:48:02 CEST 2009


Hi Bastian,

Bastian Waidelich schrieb:
> Susanne Moog wrote:

>> I have my pagebrowser now built as a viewhelper
> 
> Ah, interesting stuff. If you want to share it, don't hesitate ;)
> 

it's part of my new "addresses" extension, so anyone who wants to can
"steal" the code for the pagebrowser from forge ;-)

>> If you have another idea or would
> 
> Generally I think it's fine to load other view helpers and call their
> render-method - though, for the translate vh that might be a bit
> difficult as it gets it's default value from $this->renderChildren().

Yep, difficult. I just tried it and ran into multiple fatal errors... So
I have to ask again here :-( Is there a way to get a translation of a
label without rebuilding the translate view helper in my own view helper
(something like the getLL methods)?

> But it should work nevertheless.
> In a future release we might have something like view helper templates
> in fluid:
> 
> <my:pageBrowser>
>     <f:template>....</f:template>
> </my:pageBrowser>
> 
> for widget view helpers.. But there are no concrete plans yet.

That's really a nice thought, additionally it would be nice if it was
possible to give a "global" parameter to a namespace. For example I
wanted to have my pageBrowser at first like this:

<pagebrowser:previous>previous</pagebrowser:previous> some text here
<pagebrowser:next>next</pagebrowser:next>

So I would be able to use the translate viewhelper for all the texts and
get smaller "pagebrowser chunks". But as I need to give every part of
the pagebrowser the totalItemCount (coming from the controller over the
template to the viewhelper) I would have needed a parameter in every
chunk like:

<pagebrowser:previous
totalItemCount="{addresses.total}">previous</pagebrowser:previous> some
text here <pagebrowser:next
totalItemCount="{addresses.total}">next</pagebrowser:next>

So I decided to just have one pagebrowser tag and render everything
inside PHP. (This is not meant as complaining but as a side note about
the problems I had :-))

> 
>>> You can simply get it through the objectFactory:
>>> $this->objectFactory->create($viewHelperName);
> 
> One note regarding the extbase "object factory":
> In TYPO3 v4 you could call t3lib_div::makeInstance() directly of course.
> But Tx_Fluid_Compatibility_ObjectFactory fakes FLOW3s dependency
> injection thus resolving required dependencies for known classes and
> their derivates.

If I did it right I need to call
$this->objectFactory =
t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectFactory'); this
before I can use $this->objectFactory (it's empty if I don't call that)

>> public function render($items=NULL,$max=5) {
> 
> you might want to rethink the naming of those parameters. items & max
> are quite general and the meaning of the parameters is not very clear at
> first glance. Obviously this is not really extbase/fluid related. But
> the infamous "ubiquitous language" is an important part of DDD which is
> the aim of FLOW3 & extbas - so I mention it.

public function
render($totalCountOfAddresses=NULL,$maxAddressesToDisplay=5) <-- better?
*g* Now even an outsider will know what they mean (do I really want
this? ...just kidding)

> I'd move the name of the page-pointer ('page') to the render arguments
> in order to be more flexible.

I don't understand this sentence. Do you mean that you would use
something like

public function
render($totalCountOfAddresses=NULL,$maxAddressesToDisplay=5,
$pagePointer=0) ?



Whoops, the post got a bit longer than I wanted to, sorry ;)

Thanks for all your help (I've put some of it into the wiki for others
to find: http://wiki.typo3.org/Fluid [I know that it's also extbase, but
I've had already created that page when I recognized that]).

Susanne

-- 
Susanne Moog
NEUSTA GmbH - www.neusta.de


More information about the TYPO3-project-typo3v4mvc mailing list