Bug #30937

CropViewHelper stringToTruncate can't be supplied so it can't be easily extended

Added by Thomas Allmer over 9 years ago. Updated over 9 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
ViewHelpers
Target version:
-
Start date:
2011-10-14
Due date:
% Done:

100%

Estimated time:
Has patch:
Yes

Description

the CropViewHelper always gets its content via $this->renderChildren(); so you can't provide the text when using the Inline notation. It also makes it pretty hard to extend this viewhelper.

It should be like it is with most of the other viewhelper:
- add optional $stringToTruncate parameter
- set it to $this->renderChildren() if NULL
- see change below

    /**
     * Render the cropped text
     *
     * @param integer $maxCharacters Place where to truncate the string
     * @param string $stringToTruncate What do you want to crop
     * @param string $append What to append, if truncation happened
     * @param boolean $respectBoundaries If TRUE and division is in the middle of a word, the remains of that word is removed.
     * @param boolean $respectHtml If TRUE the cropped string will respect HTML tags and entities. Technically that means, that cropHTML() is called rather than crop()
     * @return string cropped text
     * @author Andreas Pattynama <andreas.pattynama@innocube.ch>
     * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
     * @author Bastian Waidelich <bastian@typo3.org>
     * @author Felix Oertel <oertel@networkteam.com>
     */
    public function render($maxCharacters, $stringToTruncate = NULL, $append = '...', $respectWordBoundaries = TRUE, $respectHtml = TRUE) {
        if ($stringToTruncate === NULL) {
            $stringToTruncate = $this->renderChildren();
        }

No data to display

Also available in: Atom PDF