[TYPO3-mvc] Extend CropViewhelper

Sebastian Schreiber me at schreibersebastian.de
Mon Oct 10 09:17:26 CEST 2011


Maybe this helps and make you feel better:

Introduce a member variable in your class overrite the renderChildren 
method in your class and return your
variable.

Right?

Am 10.10.2011 01:00, schrieb Thomas Allmer:
> 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


-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 217 / 5269 / 4675



More information about the TYPO3-project-typo3v4mvc mailing list