MenuProcessor implements DataProcessorInterface
This menu processor generates a menu array that will be 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 } } }
Table of Contents
Interfaces
- DataProcessorInterface
- Interface for data processor classes processing data from ContentObjectRenderer, used e.g. with the FLUIDTEMPLATE content object
Properties
- $allowedConfigurationKeys : array<string|int, mixed>
- Allowed configuration keys for menu generation, other keys will throw an exception to prevent configuration errors.
- $menuDefaults : array<string|int, mixed>
- $removeConfigurationKeysForHmenu : array<string|int, mixed>
- Remove keys from configuration that should not be passed to HMENU to prevent configuration errors
- $cObj : ContentObjectRenderer|null
- The content object renderer
- $contentDataProcessor : ContentDataProcessor
- $menuAlternativeSortingField : string
- $menuConfig : array<string|int, mixed>
- $menuContentObjectFactory : MenuContentObjectFactory
- $menuExpandAll : int
- $menuIncludeSpacer : int
- $menuLevels : int
- $menuTargetVariableName : string
- $menuTitleField : string
- $processorConfiguration : array<string|int, mixed>
- The processor configuration
Methods
- __construct() : mixed
- buildConfiguration() : void
- Build the menu configuration so it can be treated by TMENU
- prepareConfiguration() : void
- process() : array<string|int, mixed>
- Process content object data
- validateConfiguration() : void
- getConfigurationValue() : string
- Get configuration value from processorConfiguration
- processAdditionalDataProcessors() : array<string|int, mixed>
- Process additional data processors
Properties
$allowedConfigurationKeys
Allowed configuration keys for menu generation, other keys will throw an exception to prevent configuration errors.
public
array<string|int, mixed>
$allowedConfigurationKeys
= ['cache', 'cache.', 'cache_period', 'entryLevel', 'entryLevel.', 'special', 'special.', 'minItems', 'minItems.', 'maxItems', 'maxItems.', 'begin', 'begin.', 'alternativeSortingField', 'alternativeSortingField.', 'showAccessRestrictedPages', 'showAccessRestrictedPages.', 'excludeUidList', 'excludeUidList.', 'excludeDoktypes', 'includeNotInMenu', 'includeNotInMenu.', 'alwaysActivePIDlist', 'alwaysActivePIDlist.', 'protectLvar', 'addQueryString', 'addQueryString.', 'if', 'if.', 'levels', 'levels.', 'expandAll', 'expandAll.', 'includeSpacer', 'includeSpacer.', 'as', 'titleField', 'titleField.', 'dataProcessing', 'dataProcessing.']
$menuDefaults
public
array<string|int, mixed>
$menuDefaults
= ['levels' => 1, 'expandAll' => 1, 'includeSpacer' => 0, 'as' => 'menu', 'titleField' => 'nav_title // title']
$removeConfigurationKeysForHmenu
Remove keys from configuration that should not be passed to HMENU to prevent configuration errors
public
array<string|int, mixed>
$removeConfigurationKeysForHmenu
= ['levels', 'levels.', 'expandAll', 'expandAll.', 'includeSpacer', 'includeSpacer.', 'as', 'titleField', 'titleField.', 'dataProcessing', 'dataProcessing.']
$cObj
The content object renderer
protected
ContentObjectRenderer|null
$cObj
= null
$contentDataProcessor
protected
ContentDataProcessor
$contentDataProcessor
$menuAlternativeSortingField
protected
string
$menuAlternativeSortingField
$menuConfig
protected
array<string|int, mixed>
$menuConfig
= []
$menuContentObjectFactory
protected
MenuContentObjectFactory
$menuContentObjectFactory
$menuExpandAll
protected
int
$menuExpandAll
$menuIncludeSpacer
protected
int
$menuIncludeSpacer
$menuLevels
protected
int
$menuLevels
$menuTargetVariableName
protected
string
$menuTargetVariableName
$menuTitleField
protected
string
$menuTitleField
$processorConfiguration
The processor configuration
protected
array<string|int, mixed>
$processorConfiguration
Methods
__construct()
public
__construct(ContentDataProcessor $contentDataProcessor, MenuContentObjectFactory $menuContentObjectFactory) : mixed
Parameters
- $contentDataProcessor : ContentDataProcessor
- $menuContentObjectFactory : MenuContentObjectFactory
buildConfiguration()
Build the menu configuration so it can be treated by TMENU
public
buildConfiguration() : void
prepareConfiguration()
public
prepareConfiguration() : void
process()
Process content object data
public
process(ContentObjectRenderer $cObj, array<string|int, mixed> $contentObjectConfiguration, array<string|int, mixed> $processorConfiguration, array<string|int, mixed> $processedData) : array<string|int, mixed>
Parameters
- $cObj : ContentObjectRenderer
-
The data of the content element or page
- $contentObjectConfiguration : array<string|int, mixed>
-
The configuration of Content Object
- $processorConfiguration : array<string|int, mixed>
-
The configuration of this processor
- $processedData : array<string|int, mixed>
-
Key/value store of processed data (e.g. to be passed to a Fluid View)
Return values
array<string|int, mixed> —the processed data as key/value store
validateConfiguration()
public
validateConfiguration() : void
Tags
getConfigurationValue()
Get configuration value from processorConfiguration
protected
getConfigurationValue(string $key) : string
Parameters
- $key : string
Return values
stringprocessAdditionalDataProcessors()
Process additional data processors
protected
processAdditionalDataProcessors(array<string|int, mixed> $page, array<string|int, mixed> $processorConfiguration) : array<string|int, mixed>
Parameters
- $page : array<string|int, mixed>
- $processorConfiguration : array<string|int, mixed>