[TYPO3-mvc] Extend CropViewhelper

Thomas Allmer at at delusionworld.com
Mon Oct 10 13:50:37 CEST 2011


On 10.10.2011 09:17, Sebastian Schreiber wrote:
> 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?

probably not :p

changing the renderChildren method won't change how the parent will 
fetch it's string... so it won't help :p unless I extend the Crop with a 
"CropFix" overwriting the renderChildren there and then extend from the 
"CropFix" instead of the normal Crop... but than again this looks even 
more ugly :p and if I would crop I would certainly only change the 
render method so I could pass the string to use and not temper with the 
renderChildren :p

more ideas? :p

> 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
>
>


-- 
+---------------------------------+-----------------------------------+
| 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