TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface

Public Member Functions

 render ($maxCharacters, $append='...', $respectWordBoundaries=true, $respectHtml=true)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 isEscapingInterceptorEnabled ()
 
 setViewHelperNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
 
 setRenderChildrenClosure (\Closure $renderChildrenClosure)
 
 initializeArgumentsAndRender ()
 
 initialize ()
 
 renderChildren ()
 
 prepareArguments ()
 
 validateArguments ()
 
 initializeArguments ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
 resetState ()
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 

Static Protected Member Functions

static simulateFrontendEnvironment ()
 
static resetFrontendEnvironment ()
 

Static Protected Attributes

static $tsfeBackup
 

Additional Inherited Members

- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 registerArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 overrideArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 callRenderMethod ()
 
 getLogger ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = null
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = true
 

Detailed Description

Use this view helper to crop the text between its opening and closing tags.

= Examples =

<f:format.crop maxCharacters="10">This is some very long text</f:format.crop> <output> This is... </output>

<f:format.crop maxCharacters="17" append="&nbsp;[more]">This is some very long text</f:format.crop> <output> This is some [more] </output>

<f:format.crop maxCharacters="10" respectWordBoundaries="false">This is some very long text</f:format.crop> <output> This is so... </output>

<f:format.crop maxCharacters="28" respectWordBoundaries="false" respectHtml="false">This is some text with HTML tags</f:format.crop> <output> This is some text with <stro </output>

{someLongText -> f:format.crop(maxCharacters: 10)} <output> someLongText cropped after 10 characters... (depending on the value of {someLongText}) </output>

Definition at line 65 of file CropViewHelper.php.

Member Function Documentation

◆ render()

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::render (   $maxCharacters,
  $append = '...',
  $respectWordBoundaries = true,
  $respectHtml = true 
)

Render the cropped text

Parameters
int$maxCharactersPlace where to truncate the string
string$appendWhat to append, if truncation happened
bool$respectWordBoundariesIf TRUE and division is in the middle of a word, the remains of that word is removed.
bool$respectHtmlIf TRUE the cropped string will respect HTML tags and entities. Technically that means, that cropHTML() is called rather than crop()
Returns
string cropped text

Definition at line 81 of file CropViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$arguments, TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$renderChildrenClosure, TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$renderingContext, TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\buildRenderChildrenClosure(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\renderStatic().

◆ resetFrontendEnvironment()

static TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::resetFrontendEnvironment ( )
staticprotected

Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()

Returns
void
See also
simulateFrontendEnvironment()

Definition at line 167 of file CropViewHelper.php.

References $GLOBALS.

◆ simulateFrontendEnvironment()

static TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::simulateFrontendEnvironment ( )
staticprotected

Sets the global variables $GLOBALS['TSFE']->csConvObj and $GLOBALS['TSFE']->renderCharset in Backend mode This somewhat hacky work around is currently needed because the crop() and cropHTML() functions of ContentObjectRenderer rely on those variables to be set

Returns
void

Definition at line 139 of file CropViewHelper.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Member Data Documentation

◆ $tsfeBackup

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::$tsfeBackup
staticprotected

Definition at line 70 of file CropViewHelper.php.