[TYPO3-mvc] Extend CropViewhelper

Thomas Allmer at at delusionworld.com
Mon Oct 10 01:00:30 CEST 2011


hey,

can I set somehow the content of the current viewhelper?
I do want to extend the CropViewHelper like this:

class Tx_Reposearch_ViewHelpers_Format_HighlightCropViewHelper extends 
Tx_Fluid_ViewHelpers_Format_CropViewHelper

so I get the string and do some modifications to it afterward I want to 
call the parent, but as Crop gets the content with 
$this->renderChildren(); I can't give my "new" string as a parameter?

I though of probably something like this but that obviously don't work 
as there is no setContent function :p
$this->setContent($stringToHighlightTruncate);
return parent::render($maxCharacters, $append, [...]);

so currently I more or less just fork the Crop viewhelper... but that 
doesn't seem right... so anyone got a better solution?

see gist for full code https://gist.github.com/1274313

I was just thinking, but in most cases I don't even need this as most 
viewhelpers do it like this and let you define the subject via parameter...
if ($subject === NULL) {
	$subject = $this->renderChildren();
}

so probably a bug report for a view?

cheers
-- 
+---------------------------------+-----------------------------------+
| Thomas Allmer                   |   http://www.delusionworld.com    |
| E-mail: at at delusionworld.com    |   phone: +43 699 16217064         |
+---------------------------------+-----------------------------------+


More information about the TYPO3-project-typo3v4mvc mailing list