[TYPO3-mvc] Accessing fluids viewhelpers
Bastian Waidelich
bastian at typo3.org
Mon May 25 12:00:50 CEST 2009
Susanne Moog wrote:
Hi Susanne,
> I have my pagebrowser now built as a viewhelper
Ah, interesting stuff. If you want to share it, don't hesitate ;)
> 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().
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.
>> 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.
> every hint is welcome!:
Ok then:
> 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.
> $currentPage = (int)$_GET['tx_addresses_pi1']['page'];
You shouldn't access superglobals from within your extensions. In
TYPO3v4 it is not recommended - in FLOW3 it might be disabled.
Instead you can get hold of the current request with:
$currentRequest = $this->variableContainer->get('view')->getRequest();
(Note: that might change in the next versions, in FLOW3 we already have
a controller context and you would call
$this->controllerContext->getRequest())
From the request you can get hold of the arguments via getArguments() /
getArgument($argumentName)
I'd move the name of the page-pointer ('page') to the render arguments
in order to be more flexible.
Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list