[TYPO3-mvc] Accessing fluids viewhelpers

Susanne Moog typo3 at susannemoog.de
Mon May 25 08:19:47 CEST 2009


Hi Bastian,

Bastian Waidelich schrieb:
> Susanne Moog wrote:
> 
>> Can someone point me to the right method?
> 
> May I ask why you need to obtain a view helper in your PHP code?

Would probably have been easier if I told you what I want to achieve ;)

I have my pagebrowser now built as a viewhelper but I want to have the
strings (like "next" and "previous") translatable --> for that I thought
it would be an easy way to call the translation viewHelper in my own
viewHelper for translating the values. If you have another idea or would
do it another way: every hint is welcome! (My main code for the
pagebrowser is below)


> You can simply get it through the objectFactory:
> 
> $this->objectFactory->create($viewHelperName);

Thanks, I'll try that!

Cheers!

Susanne


Code:
public function render($items=NULL,$max=5) {
	$pagesTotal = ceil($items/$max);
	$currentPage = (int)$_GET['tx_addresses_pi1']['page'];
	if(($currentPage+1) == $pagesTotal) {
		$next = 'next';
	} else {
		$next = $this->getLink(($currentPage+1), 'next');
	}
	if($currentPage == 0) {
		$previous = 'previous';
	} else {
		$previous = $this->getLink(($currentPage-1), 'previous');
	}

	$content = $previous . ' Page ' . ($currentPage+1)  . ' out of ' .
$pagesTotal . ' ' . $next;
	return $content;
}


More information about the TYPO3-project-typo3v4mvc mailing list