AbstractMenuContentObject

AbstractYes

Generating navigation/menus from TypoScript

The HMENU content object uses this (or more precisely one of the extension classes). Among others the class generates an array of menu items. Thereafter functions from the subclasses are called. The class is always used through extension classes like TextMenuContentObject.

Table of Contents

Constants

customItemStates  = [ // IFSUB is TRUE if there exist submenu items to the current item 'IFSUB', 'ACT', // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active 'ACTIFSUB', // CUR is TRUE if the current page equals the item here! 'CUR', // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here! 'CURIFSUB', 'USR', 'SPC', 'USERDEF1', 'USERDEF2', ]

Properties

$parent_cObj  : ContentObjectRenderer
Loaded with the parent cObj-object when a new HMENU is made
$alternativeMenuTempArray  : array<string|int, mixed>
Can be set to contain menu item arrays for sub-levels.
$alwaysActivePIDlist  : array<string|int, int>
$conf  : array<string|int, mixed>
HMENU configuration
$disableGroupAccessCheck  : bool
$entryLevel  : int
0 = rootFolder
$excludedDoktypes  : array<string|int, int>
Doktypes that define which should not be included in a menu
$hash  : string
$I  : array<string|int, mixed>
$id  : int
The base page-id of the menu.
$mconf  : array<string|int, mixed>
xMENU configuration (TMENU etc)
$menuArr  : array<string|int, array<string|int, mixed>>
The array of menuItems which is built
$menuNumber  : int
tells you which menu number this is. This is important when getting data from the setup
$MP_array  : array<string|int, string>
accumulation of mount point data
$nextActive  : string
Holds the page uid of the NEXT page in the root line from the page pointed to by entryLevel; Used to expand the menu automatically if in a certain root line.
$parentMenuArr  : array<string|int, mixed>
$parentMenuArrItemKey  : int|null
Array key of the parentMenuItem in the parentMenuArr, if this menu is a subMenu.
$request  : ServerRequestInterface
$result  : array<string|int, mixed>
$rL_uidRegister  : array<string|int, mixed>
Is filled with an array of page uid numbers + RL parameters which are in the current root line (used to evaluate whether a menu item is in active state)
$sys_page  : PageRepository
$tmpl  : TemplateService|null

Methods

filterMenuPages()  : bool
Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong, if they are hidden in navigation, have a uid in the list of banned uids etc.
generate()  : mixed
Calls processItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
getParentContentObject()  : ContentObjectRenderer
Returns the parent content object
getParentMenuArr()  : array<string|int, mixed>
Get the parentMenuArr, if this is subMenu.
getParentMenuItem()  : array<string|int, mixed>|null
Get the parentMenuItem from the parentMenuArr, if this is a subMenu
getSysPage()  : PageRepository
Returns the sys_page object
makeMenu()  : mixed
Creates the menu in the internal variables, ready for output.
setParentMenu()  : mixed
Set the parentMenuArr and key to provide the parentMenu information to the subMenu, special fur IProcFunc and itemArrayProcFunc user functions.
start()  : bool
The initialization of the object. This just sets some internal variables.
writeMenu()  : string
buildPageRepository()  : PageRepository
Builds PageRepository instance without depending on global context, e.g.
getBannedUids()  : array<string|int, mixed>
Returns an array of banned UIDs (from excludeUidList)
getCache()  : FrontendInterface
getCacheIdentifierForSubMenuDecision()  : string
getCurrentLanguageAspect()  : LanguageAspect
getCurrentSite()  : Site
Returns the currently configured "site" if a site is configured (= resolved) in the current request.
getDoktypeExcludeWhere()  : string
Returns where clause part to exclude 'not in menu' pages
getMPvar()  : string
Return MPvar string for entry $key in ->menuArr
getPageTitle()  : string
Returns the title for the navigation
getRuntimeCache()  : FrontendInterface
getTimeTracker()  : TimeTracker
getTypoScriptFrontendController()  : TypoScriptFrontendController
hasParentMenuArr()  : bool
Check if there is a valid parentMenuArr.
hasParentMenuItem()  : mixed
Check if the the parentMenuItem exists
hasParentMenuItemKey()  : mixed
Check if we have a parentMenuArrItemKey
isActive()  : bool
Returns TRUE if the given page is active (in the current rootline)
isCurrent()  : bool
Returns TRUE if the page is the CURRENT page (equals $this->getTypoScriptFrontendController()->id)
isItemState()  : bool
Used by processItemStates() to evaluate if a menu item (identified by $key) is in a certain state.
isNext()  : bool
Returns TRUE if the page with UID $uid is the NEXT page in root line (which means a submenu should be drawn)
isSubMenu()  : bool
Returns TRUE if there is a submenu with items for the page id, $uid Used by the item states "IFSUB", "ACTIFSUB" and "CURIFSUB" to check if there is a submenu
link()  : LinkResultInterface|null
Creates the URL, target and data-window-* attributes for the menu item link. Returns them in an array as key/value pairs for <A>-tag attributes
menuTypoLink()  : LinkResultInterface
Calls typolink to create menu item links.
prepareMenuItems()  : array<string|int, mixed>
Main function for retrieving menu items based on the menu type (special or sectionIndex or "normal")
prepareMenuItemsForBrowseMenu()  : array<string|int, mixed>
Fetches all menuitems if special = browse is set
prepareMenuItemsForDirectoryMenu()  : array<string|int, mixed>
Fetches all menuitems if special = directory is set
prepareMenuItemsForKeywordsMenu()  : array<string|int, mixed>
Fetches all menuitems if special = keywords is set
prepareMenuItemsForLanguageMenu()  : array<string|int, mixed>
Fetches all menuitems if special = language is set
prepareMenuItemsForListMenu()  : array<string|int, mixed>
Fetches all menuitems if special = list is set
prepareMenuItemsForRootlineMenu()  : array<string|int, mixed>
Fetches all menuitems if special = rootline is set
prepareMenuItemsForUpdatedMenu()  : array<string|int, mixed>
Fetches all menuitems if special = updated is set
prepareMenuItemsForUserSpecificMenu()  : array<string|int, mixed>
Fetches all menuitems if special = userfunction is set
processItemStates()  : array<string|int, mixed>
Generating the per-menu-item configuration arrays based on the settings for item states (NO, ACT, CUR etc) set in ->mconf (config for the current menu object) Basically it will produce an individual array for each menu item based on the item states.
removeInaccessiblePages()  : array<string|int, mixed>
Gets an array of page rows and removes all, which are not accessible
sectionIndex()  : array<string|int, mixed>
Generates a list of content objects with sectionIndex enabled available on a specific page
setATagParts()  : mixed
Creates the <A> tag parts for the current item (in $this->I, [A1] and [A2]) based on the given link result
subMenu()  : string
Creates a submenu level to the current level - if configured for.
userProcess()  : mixed
Calls a user function for processing of internal data.

Constants

customItemStates

protected mixed customItemStates = [ // IFSUB is TRUE if there exist submenu items to the current item 'IFSUB', 'ACT', // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active 'ACTIFSUB', // CUR is TRUE if the current page equals the item here! 'CUR', // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here! 'CURIFSUB', 'USR', 'SPC', 'USERDEF1', 'USERDEF2', ]

Properties

$alternativeMenuTempArray

Can be set to contain menu item arrays for sub-levels.

protected array<string|int, mixed> $alternativeMenuTempArray = []

$alwaysActivePIDlist

protected array<string|int, int> $alwaysActivePIDlist = []

$conf

HMENU configuration

protected array<string|int, mixed> $conf = []

$disableGroupAccessCheck

protected bool $disableGroupAccessCheck = false

$entryLevel

0 = rootFolder

protected int $entryLevel = 0

$excludedDoktypes

Doktypes that define which should not be included in a menu

protected array<string|int, int> $excludedDoktypes = [\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_BE_USER_SECTION, \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SYSFOLDER]

$id

The base page-id of the menu.

protected int $id

$mconf

xMENU configuration (TMENU etc)

protected array<string|int, mixed> $mconf = []

$menuArr

The array of menuItems which is built

protected array<string|int, array<string|int, mixed>> $menuArr

$menuNumber

tells you which menu number this is. This is important when getting data from the setup

protected int $menuNumber = 1

$MP_array

accumulation of mount point data

protected array<string|int, string> $MP_array = []

$nextActive

Holds the page uid of the NEXT page in the root line from the page pointed to by entryLevel; Used to expand the menu automatically if in a certain root line.

protected string $nextActive

$parentMenuArr

protected array<string|int, mixed> $parentMenuArr

$parentMenuArrItemKey

Array key of the parentMenuItem in the parentMenuArr, if this menu is a subMenu.

protected int|null $parentMenuArrItemKey

$request

protected ServerRequestInterface $request

$result

protected array<string|int, mixed> $result = []

$rL_uidRegister

Is filled with an array of page uid numbers + RL parameters which are in the current root line (used to evaluate whether a menu item is in active state)

protected array<string|int, mixed> $rL_uidRegister

$tmpl

Deprecated

since v12: Remove property and usages in v13 when TemplateService is removed

protected TemplateService|null $tmpl

Methods

filterMenuPages()

Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong, if they are hidden in navigation, have a uid in the list of banned uids etc.

public filterMenuPages(array<string|int, mixed> &$data, array<string|int, mixed> $banUidArray, bool $isSpacerPage) : bool
Parameters
$data : array<string|int, mixed>

Array of menu items

$banUidArray : array<string|int, mixed>

Array of page uids which are to be excluded

$isSpacerPage : bool

If set, then the page is a spacer.

Tags
throws
UnexpectedValueException
Return values
bool

Returns TRUE if the page can be safely included.

generate()

Calls processItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.

public generate() : mixed

Sets the result for the new "normal state" in $this->result

Tags
see
AbstractMenuContentObject::processItemStates()

getParentMenuArr()

Get the parentMenuArr, if this is subMenu.

public getParentMenuArr() : array<string|int, mixed>
Return values
array<string|int, mixed>

getParentMenuItem()

Get the parentMenuItem from the parentMenuArr, if this is a subMenu

public getParentMenuItem() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

makeMenu()

Creates the menu in the internal variables, ready for output.

public makeMenu() : mixed

Basically this will read the page records needed and fill in the internal $this->menuArr Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real.

setParentMenu()

Set the parentMenuArr and key to provide the parentMenu information to the subMenu, special fur IProcFunc and itemArrayProcFunc user functions.

public setParentMenu(array<string|int, mixed> $menuArr, int $menuItemKey) : mixed
Parameters
$menuArr : array<string|int, mixed>
$menuItemKey : int
Internal

start()

The initialization of the object. This just sets some internal variables.

public start(TemplateService|null $_, PageRepository $sys_page, int|string $id, array<string|int, mixed> $conf, int $menuNumber[, string $objSuffix = '' ][, ServerRequestInterface|null $request = null ]) : bool
Parameters
$_ : TemplateService|null

Obsolete argument

$sys_page : PageRepository

The $this->getTypoScriptFrontendController()->sys_page object

$id : int|string

A starting point page id. This should probably be blank since the 'entryLevel' value will be used then.

$conf : array<string|int, mixed>

The TypoScript configuration for the HMENU cObject

$menuNumber : int

Menu number; 1,2,3. Should probably be 1

$objSuffix : string = ''

Submenu Object suffix. This offers submenus a way to use alternative configuration for specific positions in the menu; By default "1 = TMENU" would use "1." for the TMENU configuration, but if this string is set to eg. "a" then "1a." would be used for configuration instead (while "1 = " is still used for the overall object definition of "TMENU")

$request : ServerRequestInterface|null = null
Tags
see
ContentObjectRenderer::HMENU()
Return values
bool

Returns TRUE on success

writeMenu()

public writeMenu() : string
Return values
string

The HTML for the menu

buildPageRepository()

Builds PageRepository instance without depending on global context, e.g.

protected buildPageRepository([LanguageAspect|null $languageAspect = null ]) : PageRepository

not automatically overlaying records based on current request language.

Parameters
$languageAspect : LanguageAspect|null = null
Return values
PageRepository

getBannedUids()

Returns an array of banned UIDs (from excludeUidList)

protected getBannedUids() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of banned UIDs

getCacheIdentifierForSubMenuDecision()

protected getCacheIdentifierForSubMenuDecision(mixed $uid) : string
Parameters
$uid : mixed
Return values
string

getCurrentSite()

Returns the currently configured "site" if a site is configured (= resolved) in the current request.

protected getCurrentSite() : Site
Return values
Site

getDoktypeExcludeWhere()

Returns where clause part to exclude 'not in menu' pages

protected getDoktypeExcludeWhere() : string
Return values
string

where clause part.

getMPvar()

Return MPvar string for entry $key in ->menuArr

protected getMPvar(int $key) : string
Parameters
$key : int

Pointer to element in ->menuArr

Tags
see
link()
Return values
string

MP vars for element.

getPageTitle()

Returns the title for the navigation

protected getPageTitle(string $title, string $nav_title) : string
Parameters
$title : string

The current page title

$nav_title : string

The current value of the navigation title

Return values
string

Returns the navigation title if it is NOT blank, otherwise the page title.

hasParentMenuArr()

Check if there is a valid parentMenuArr.

protected hasParentMenuArr() : bool
Return values
bool

hasParentMenuItem()

Check if the the parentMenuItem exists

protected hasParentMenuItem() : mixed

hasParentMenuItemKey()

Check if we have a parentMenuArrItemKey

protected hasParentMenuItemKey() : mixed

isActive()

Returns TRUE if the given page is active (in the current rootline)

protected isActive(array<string|int, mixed> $page, string $MPvar) : bool
Parameters
$page : array<string|int, mixed>

Page record to evaluate.

$MPvar : string

MPvar for the current position of item.

Return values
bool

TRUE if $page is active

isCurrent()

Returns TRUE if the page is the CURRENT page (equals $this->getTypoScriptFrontendController()->id)

protected isCurrent(array<string|int, mixed> $page, string $MPvar) : bool
Parameters
$page : array<string|int, mixed>

Page record to evaluate.

$MPvar : string

MPvar for the current position of item.

Return values
bool

TRUE if resolved page ID = $this->getTypoScriptFrontendController()->id

isItemState()

Used by processItemStates() to evaluate if a menu item (identified by $key) is in a certain state.

protected isItemState(string $kind, int $key) : bool
Parameters
$kind : string

The item state to evaluate (SPC, IFSUB, ACT etc...)

$key : int

Key pointing to menu item from ->menuArr

Tags
see
processItemStates()
Return values
bool

Returns TRUE if state matches

isNext()

Returns TRUE if the page with UID $uid is the NEXT page in root line (which means a submenu should be drawn)

protected isNext(int $uid, string $MPvar) : bool
Parameters
$uid : int

Page uid to evaluate.

$MPvar : string

MPvar for the current position of item.

Tags
see
subMenu()
Return values
bool

TRUE if page with $uid is active

isSubMenu()

Returns TRUE if there is a submenu with items for the page id, $uid Used by the item states "IFSUB", "ACTIFSUB" and "CURIFSUB" to check if there is a submenu

protected isSubMenu(int $uid) : bool
Parameters
$uid : int

Page uid for which to search for a submenu

Return values
bool

Returns TRUE if there was a submenu with items found

Creates the URL, target and data-window-* attributes for the menu item link. Returns them in an array as key/value pairs for <A>-tag attributes

protected link(int $key, string $altTarget, string $typeOverride) : LinkResultInterface|null
Parameters
$key : int

Pointer to a key in the $this->menuArr array where the value for that key represents the menu item we are linking to (page record)

$altTarget : string

Alternative target

$typeOverride : string

Alternative type

Return values
LinkResultInterface|null

Calls typolink to create menu item links.

protected menuTypoLink(array<string|int, mixed> $page, string $oTarget, string $addParams, int|string $typeOverride[, int|null $overridePageId = null ]) : LinkResultInterface
Parameters
$page : array<string|int, mixed>

Page record (uid points where to link to)

$oTarget : string

Target frame/window

$addParams : string

Parameters to add to URL

$typeOverride : int|string

"type" value, empty string means "not set"

$overridePageId : int|null = null

link to this page instead of the $page[uid] value

Return values
LinkResultInterface

prepareMenuItems()

Main function for retrieving menu items based on the menu type (special or sectionIndex or "normal")

protected prepareMenuItems() : array<string|int, mixed>
Return values
array<string|int, mixed>

prepareMenuItemsForBrowseMenu()

Fetches all menuitems if special = browse is set

protected prepareMenuItemsForBrowseMenu(string $specialValue, string $sortingField, string $additionalWhere) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

$sortingField : string

The sorting field

$additionalWhere : string

Additional WHERE clause

Return values
array<string|int, mixed>

prepareMenuItemsForDirectoryMenu()

Fetches all menuitems if special = directory is set

protected prepareMenuItemsForDirectoryMenu(string $specialValue, string $sortingField) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

$sortingField : string

The sorting field

Return values
array<string|int, mixed>

prepareMenuItemsForKeywordsMenu()

Fetches all menuitems if special = keywords is set

protected prepareMenuItemsForKeywordsMenu(string $specialValue, string $sortingField) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

$sortingField : string

The sorting field

Return values
array<string|int, mixed>

prepareMenuItemsForLanguageMenu()

Fetches all menuitems if special = language is set

protected prepareMenuItemsForLanguageMenu(string $specialValue) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

Return values
array<string|int, mixed>

prepareMenuItemsForListMenu()

Fetches all menuitems if special = list is set

protected prepareMenuItemsForListMenu(string $specialValue) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

Return values
array<string|int, mixed>

prepareMenuItemsForRootlineMenu()

Fetches all menuitems if special = rootline is set

protected prepareMenuItemsForRootlineMenu() : array<string|int, mixed>
Return values
array<string|int, mixed>

prepareMenuItemsForUpdatedMenu()

Fetches all menuitems if special = updated is set

protected prepareMenuItemsForUpdatedMenu(string $specialValue, string $sortingField) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

$sortingField : string

The sorting field

Return values
array<string|int, mixed>

prepareMenuItemsForUserSpecificMenu()

Fetches all menuitems if special = userfunction is set

protected prepareMenuItemsForUserSpecificMenu(string $specialValue, string $sortingField) : array<string|int, mixed>
Parameters
$specialValue : string

The value from special.value

$sortingField : string

The sorting field

Return values
array<string|int, mixed>

processItemStates()

Generating the per-menu-item configuration arrays based on the settings for item states (NO, ACT, CUR etc) set in ->mconf (config for the current menu object) Basically it will produce an individual array for each menu item based on the item states.

protected processItemStates(int $splitCount) : array<string|int, mixed>

BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved. Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.

Parameters
$splitCount : int

Number of menu items in the menu

Return values
array<string|int, mixed>

the resolved configuration for each item

removeInaccessiblePages()

Gets an array of page rows and removes all, which are not accessible

protected removeInaccessiblePages(array<string|int, mixed> $pages) : array<string|int, mixed>
Parameters
$pages : array<string|int, mixed>
Return values
array<string|int, mixed>

sectionIndex()

Generates a list of content objects with sectionIndex enabled available on a specific page

protected sectionIndex(string $altSortField[, int $pid = null ]) : array<string|int, mixed>

Used for menus with sectionIndex enabled

Parameters
$altSortField : string

Alternative sorting field

$pid : int = null

The page id to search for sections

Tags
throws
UnexpectedValueException

if the query to fetch the content elements unexpectedly fails

Return values
array<string|int, mixed>

setATagParts()

Creates the <A> tag parts for the current item (in $this->I, [A1] and [A2]) based on the given link result

protected setATagParts(LinkResultInterface|null $linkResult) : mixed
Parameters
$linkResult : LinkResultInterface|null

subMenu()

Creates a submenu level to the current level - if configured for.

protected subMenu(int $uid, string $objSuffix, int $menuItemKey) : string
Parameters
$uid : int

Page id of the current page for which a submenu MAY be produced (if conditions are met)

$objSuffix : string

Object prefix, see ->start()

$menuItemKey : int
Return values
string

HTML content of the submenu

userProcess()

Calls a user function for processing of internal data.

protected userProcess(string $mConfKey, mixed $passVar) : mixed

Used for the properties "IProcFunc" and "itemArrayProcFunc"

Parameters
$mConfKey : string

Key pointing for the property in the current ->mconf array holding possibly parameters to pass along to the function/method. Currently the keys used are "IProcFunc" and "itemArrayProcFunc".

$passVar : mixed

A variable to pass to the user function and which should be returned again from the user function. The idea is that the user function modifies this variable according to what you want to achieve and then returns it. For "itemArrayProcFunc" this variable is $this->menuArr, for "IProcFunc" it is $this->I

Return values
mixed

The processed $passVar


        
On this page

Search results