Bug #30937

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

Added by Thomas Allmer almost 4 years ago. Updated almost 4 years ago.

Status:New Start date:2011-10-14
Priority:Should have Due date:
Assigned To:- % Done:

100%

Category:ViewHelpers
Target version:-
Has patch:Yes Affected Flow version:FLOW3 1.0.0

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();
        }

History

#1 Updated by Karsten Dambekalns almost 4 years ago

  • Affected Flow version set to FLOW3 1.0.0

Also available in: Atom PDF