‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\DataProcessing\MenuProcessor Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\DataProcessing\MenuProcessor:
TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface

Public Member Functions

 __construct (protected ContentDataProcessor $contentDataProcessor, protected ContentObjectFactory $contentObjectFactory)
 
 setContentObjectRenderer (ContentObjectRenderer $cObj)
 
 validateConfiguration ()
 
 prepareConfiguration ()
 
 prepareLevelConfiguration ()
 
 prepareLevelLanguageConfiguration ()
 
 buildConfiguration ()
 
array process (ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
 
string getDataAsJson ()
 
string jsonEncodeUserFunc ($content, $conf)
 
string jsonEncode ($value)
 
array replacePlaceholderInRenderedMenuItem ($menuItem, $conf)
 

Public Attributes

const LINK_PLACEHOLDER = '###LINKPLACEHOLDER###'
 
const TARGET_PLACEHOLDER = '###TARGETPLACEHOLDER###'
 
array $allowedConfigurationKeys
 
array $removeConfigurationKeysForHmenu
 
array $menuDefaults
 

Protected Member Functions

string getConfigurationValue ($key)
 
array processAdditionalDataProcessors ($page, $processorConfiguration)
 

Protected Attributes

ContentObjectRenderer $cObj = null
 
array $processorConfiguration
 
array $menuConfig
 
array $menuLevelConfig
 
int $menuLevels
 
int $menuExpandAll
 
int $menuIncludeSpacer
 
string $menuTitleField
 
string $menuAlternativeSortingField
 
string $menuTargetVariableName
 

Detailed Description

This menu processor utilizes HMENU to generate a json encoded menu string that will be decoded again and assigned to FLUIDTEMPLATE as variable. Additional DataProcessing is supported and will be applied to each record.

Options: as - The variable to be used within the result levels - Number of levels of the menu expandAll = If false, submenus will only render if the parent page is active includeSpacer = If true, pagetype spacer will be included in the menu titleField = Field that should be used for the title

See HMENU docs for more options. https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.html

Example TypoScript configuration:

10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor 10 { special = list special.value.field = pages levels = 7 as = menu expandAll = 1 includeSpacer = 1 titleField = nav_title // title dataProcessing { 10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor 10 { references.fieldName = media } } }

Definition at line 61 of file MenuProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::__construct ( protected ContentDataProcessor  $contentDataProcessor,
protected ContentObjectFactory  $contentObjectFactory 
)

Definition at line 240 of file MenuProcessor.php.

Member Function Documentation

◆ buildConfiguration()

◆ getConfigurationValue()

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::getConfigurationValue (   $key)
protected

Get configuration value from processorConfiguration

Parameters
string$key
Returns
‪string

Definition at line 260 of file MenuProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\process().

◆ getDataAsJson()

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::getDataAsJson ( )

Gets the data of the current record in JSON format

Returns
‪string JSON encoded data

Definition at line 483 of file MenuProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\jsonEncode().

◆ jsonEncode()

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::jsonEncode (   $value)

◆ jsonEncodeUserFunc()

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::jsonEncodeUserFunc (   $content,
  $conf 
)

This UserFunc encodes the content as Json

Parameters
string$content
array$conf
Returns
‪string JSON encoded content

Definition at line 495 of file MenuProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\jsonEncode().

◆ prepareConfiguration()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::prepareConfiguration ( )

◆ prepareLevelConfiguration()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::prepareLevelConfiguration ( )

Prepare configuration for a certain menu level in the hierarchy

Definition at line 305 of file MenuProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\process().

◆ prepareLevelLanguageConfiguration()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::prepareLevelLanguageConfiguration ( )

Prepare the configuration when rendering a language menu

Definition at line 320 of file MenuProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\process().

◆ process()

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::process ( ContentObjectRenderer  $cObj,
array  $contentObjectConfiguration,
array  $processorConfiguration,
array  $processedData 
)

◆ processAdditionalDataProcessors()

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::processAdditionalDataProcessors (   $page,
  $processorConfiguration 
)
protected

Process additional data processors

Parameters
array$page
array$processorConfiguration
Returns
‪array

Definition at line 463 of file MenuProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\$processorConfiguration.

Referenced by TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\process().

◆ replacePlaceholderInRenderedMenuItem()

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::replacePlaceholderInRenderedMenuItem (   $menuItem,
  $conf 
)

This UserFunc gets the link and the target

Parameters
array$menuItem
array$conf
Returns
‪array

Definition at line 519 of file MenuProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\jsonEncode().

◆ setContentObjectRenderer()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::setContentObjectRenderer ( ContentObjectRenderer  $cObj)

This is called from UserContentObject via ContentObjectRenderer->callUserFunction() for nested menu items - those use a USER content object for getDataAsJson().

Definition at line 249 of file MenuProcessor.php.

References TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\$cObj.

◆ validateConfiguration()

TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::validateConfiguration ( )

Validate configuration

Exceptions

Definition at line 270 of file MenuProcessor.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\MenuProcessor\process().

Member Data Documentation

◆ $allowedConfigurationKeys

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$allowedConfigurationKeys

Allowed configuration keys for menu generation, other keys will throw an exception to prevent configuration errors.

Definition at line 82 of file MenuProcessor.php.

◆ $cObj

ContentObjectRenderer TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$cObj = null
protected

◆ $menuAlternativeSortingField

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuAlternativeSortingField
protected

◆ $menuConfig

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuConfig
protected
Initial value:
= array(
'wrap' => '[|]',
)

Definition at line 146 of file MenuProcessor.php.

◆ $menuDefaults

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuDefaults
Initial value:
= array(
'levels' => 1,
'expandAll' => 1,
'includeSpacer' => 0,
'as' => 'menu',
'titleField' => 'nav_title // title',
)

Definition at line 208 of file MenuProcessor.php.

◆ $menuExpandAll

int TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuExpandAll
protected

◆ $menuIncludeSpacer

int TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuIncludeSpacer
protected

Definition at line 226 of file MenuProcessor.php.

◆ $menuLevelConfig

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuLevelConfig
protected

◆ $menuLevels

int TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuLevels
protected

◆ $menuTargetVariableName

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuTargetVariableName
protected

◆ $menuTitleField

string TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$menuTitleField
protected

Definition at line 230 of file MenuProcessor.php.

◆ $processorConfiguration

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$processorConfiguration
protected

◆ $removeConfigurationKeysForHmenu

array TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::$removeConfigurationKeysForHmenu
Initial value:
= array(
'levels',
'levels.',
'expandAll',
'expandAll.',
'includeSpacer',
'includeSpacer.',
'as',
'titleField',
'titleField.',
'dataProcessing',
'dataProcessing.',
)

Remove keys from configuration that should not be passed to HMENU to prevent configuration errors

Definition at line 130 of file MenuProcessor.php.

◆ LINK_PLACEHOLDER

const TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::LINK_PLACEHOLDER = '###LINKPLACEHOLDER###'

Definition at line 63 of file MenuProcessor.php.

◆ TARGET_PLACEHOLDER

const TYPO3\CMS\Frontend\DataProcessing\MenuProcessor::TARGET_PLACEHOLDER = '###TARGETPLACEHOLDER###'

Definition at line 64 of file MenuProcessor.php.