MenuProcessor implements DataProcessorInterface
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 } } }
Table of Contents
Interfaces
- DataProcessorInterface
- Interface for data processor classes processing data from ContentObjectRenderer, used e.g. with the FLUIDTEMPLATE content object
Constants
- LINK_PLACEHOLDER = '###LINKPLACEHOLDER###'
- TARGET_PLACEHOLDER = '###TARGETPLACEHOLDER###'
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
- The content object renderer
- $contentDataProcessor : ContentDataProcessor
- $menuAlternativeSortingField : string
- $menuConfig : array<string|int, mixed>
- $menuExpandAll : int
- $menuIncludeSpacer : int
- $menuLevelConfig : array<string|int, mixed>
- $menuLevels : int
- $menuTargetVariableName : string
- $menuTitleField : string
- $processorConfiguration : array<string|int, mixed>
- The processor configuration
Methods
- __construct() : mixed
- Constructor
- buildConfiguration() : mixed
- Build the menu configuration so it can be treated by HMENU cObject
- getDataAsJson() : string
- Gets the data of the current record in JSON format
- jsonEncode() : string
- JSON Encode
- jsonEncodeUserFunc() : string
- This UserFunc encodes the content as Json
- prepareConfiguration() : mixed
- Prepare Configuration
- prepareLevelConfiguration() : mixed
- Prepare configuration for a certain menu level in the hierarchy
- prepareLevelLanguageConfiguration() : mixed
- Prepare the configuration when rendering a language menu
- process() : array<string|int, mixed>
- Process content object data
- replacePlaceholderInRenderedMenuItem() : array<string|int, mixed>
- This UserFunc gets the link and the target
- setContentObjectRenderer() : void
- This is called from UserContentObject via ContentObjectRenderer->callUserFunction() for nested menu items - those use a USER content object for getDataAsJson().
- validateConfiguration() : mixed
- Validate configuration
- getConfigurationValue() : string
- Get configuration value from processorConfiguration
- getCurrentSite() : SiteInterface
- Returns the currently configured "site" if a site is configured (= resolved) in the current request.
- getTypoScriptFrontendController() : TypoScriptFrontendController
- processAdditionalDataProcessors() : array<string|int, mixed>
- Process additional data processors
Constants
LINK_PLACEHOLDER
public
mixed
LINK_PLACEHOLDER
= '###LINKPLACEHOLDER###'
TARGET_PLACEHOLDER
public
mixed
TARGET_PLACEHOLDER
= '###TARGETPLACEHOLDER###'
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
$cObj
= null
$contentDataProcessor
protected
ContentDataProcessor
$contentDataProcessor
$menuAlternativeSortingField
protected
string
$menuAlternativeSortingField
$menuConfig
protected
array<string|int, mixed>
$menuConfig
= ['wrap' => '[|]']
$menuExpandAll
protected
int
$menuExpandAll
$menuIncludeSpacer
protected
int
$menuIncludeSpacer
$menuLevelConfig
protected
array<string|int, mixed>
$menuLevelConfig
= ['doNotLinkIt' => '1', 'wrapItemAndSub' => '{|}, |*| {|}, |*| {|}', 'stdWrap.' => ['cObject' => 'COA', 'cObject.' => ['10' => 'USER', '10.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\MenuProcessor->getDataAsJson', 'stdWrap.' => ['wrap' => '"data":|']], '20' => 'TEXT', '20.' => ['field' => 'nav_title // title', 'trim' => '1', 'wrap' => ',"title":|', 'preUserFunc' => 'TYPO3\CMS\Frontend\DataProcessing\MenuProcessor->jsonEncodeUserFunc'], '21' => 'TEXT', '21.' => ['value' => self::LINK_PLACEHOLDER, 'wrap' => ',"link":|'], '22' => 'TEXT', '22.' => ['value' => self::TARGET_PLACEHOLDER, 'wrap' => ',"target":|'], '30' => 'TEXT', '30.' => ['value' => '0', 'wrap' => ',"active":|'], '40' => 'TEXT', '40.' => ['value' => '0', 'wrap' => ',"current":|'], '50' => 'TEXT', '50.' => ['value' => '0', 'wrap' => ',"spacer":|'], '60' => 'TEXT', '60.' => ['value' => '0', 'wrap' => ',"hasSubpages":|']]]]
$menuLevels
protected
int
$menuLevels
$menuTargetVariableName
protected
string
$menuTargetVariableName
$menuTitleField
protected
string
$menuTitleField
$processorConfiguration
The processor configuration
protected
array<string|int, mixed>
$processorConfiguration
Methods
__construct()
Constructor
public
__construct() : mixed
buildConfiguration()
Build the menu configuration so it can be treated by HMENU cObject
public
buildConfiguration() : mixed
getDataAsJson()
Gets the data of the current record in JSON format
public
getDataAsJson() : string
Return values
string —JSON encoded data
jsonEncode()
JSON Encode
public
jsonEncode(mixed $value) : string
Parameters
- $value : mixed
Return values
stringjsonEncodeUserFunc()
This UserFunc encodes the content as Json
public
jsonEncodeUserFunc(string $content, array<string|int, mixed> $conf) : string
Parameters
- $content : string
- $conf : array<string|int, mixed>
Return values
string —JSON encoded content
prepareConfiguration()
Prepare Configuration
public
prepareConfiguration() : mixed
prepareLevelConfiguration()
Prepare configuration for a certain menu level in the hierarchy
public
prepareLevelConfiguration() : mixed
prepareLevelLanguageConfiguration()
Prepare the configuration when rendering a language menu
public
prepareLevelLanguageConfiguration() : mixed
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
replacePlaceholderInRenderedMenuItem()
This UserFunc gets the link and the target
public
replacePlaceholderInRenderedMenuItem(array<string|int, mixed> $menuItem, array<string|int, mixed> $conf) : array<string|int, mixed>
Parameters
- $menuItem : array<string|int, mixed>
- $conf : array<string|int, mixed>
Return values
array<string|int, mixed>setContentObjectRenderer()
This is called from UserContentObject via ContentObjectRenderer->callUserFunction() for nested menu items - those use a USER content object for getDataAsJson().
public
setContentObjectRenderer(ContentObjectRenderer $cObj) : void
Parameters
- $cObj : ContentObjectRenderer
validateConfiguration()
Validate configuration
public
validateConfiguration() : mixed
Tags
getConfigurationValue()
Get configuration value from processorConfiguration
protected
getConfigurationValue(string $key) : string
Parameters
- $key : string
Return values
stringgetCurrentSite()
Returns the currently configured "site" if a site is configured (= resolved) in the current request.
protected
getCurrentSite() : SiteInterface
Return values
SiteInterfacegetTypoScriptFrontendController()
protected
getTypoScriptFrontendController() : TypoScriptFrontendController
Return values
TypoScriptFrontendControllerprocessAdditionalDataProcessors()
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>