TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper Tx_Fluid_ViewHelpers_Format_CropViewHelper

Public Member Functions

 injectConfigurationManager (\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
 
 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)
 
 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 ()
 

Protected Member Functions

 simulateFrontendEnvironment ()
 
 resetFrontendEnvironment ()
 
- 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 ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 

Protected Attributes

 $contentObject
 
 $tsfeBackup
 
 $configurationManager
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = NULL
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = TRUE
 

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)
 

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 57 of file CropViewHelper.php.

Member Function Documentation

◆ injectConfigurationManager()

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::injectConfigurationManager ( \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface  $configurationManager)
Parameters
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface$configurationManager
Returns
void

Definition at line 78 of file CropViewHelper.php.

References TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\$configurationManager.

◆ render()

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

Render the cropped text

Parameters
integer$maxCharactersPlace where to truncate the string
string$appendWhat to append, if truncation happened
boolean$respectWordBoundariesIf TRUE and division is in the middle of a word, the remains of that word is removed.
boolean$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 92 of file CropViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\renderChildren(), TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\resetFrontendEnvironment(), TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\simulateFrontendEnvironment(), and TYPO3_MODE.

◆ resetFrontendEnvironment()

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::resetFrontendEnvironment ( )
protected

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

Returns
void
See also
simulateFrontendEnvironment()

Definition at line 141 of file CropViewHelper.php.

References $GLOBALS, and TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\$tsfeBackup.

Referenced by TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\render().

◆ simulateFrontendEnvironment()

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::simulateFrontendEnvironment ( )
protected

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 rely on those variables to be set

Returns
void

Definition at line 114 of file CropViewHelper.php.

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

Referenced by TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper\render().

Member Data Documentation

◆ $configurationManager

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::$configurationManager
protected

◆ $contentObject

TYPO3\CMS\Fluid\ViewHelpers\Format\CropViewHelper::$contentObject
protected

Definition at line 62 of file CropViewHelper.php.

◆ $tsfeBackup

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