HMENU

Objects of type HMENU generate hierarchical menus. In a FLUIDTEMPLATE the HMENU can be used as a DataProcessor called MenuProcessor, which internally uses the HMENU functionality.

The cObject HMENU allows you to define the global settings of the menu as a whole. For the rendering of the single menu levels, different menu objects can be used.

Apart from just creating a hierarchical menu of the pages as they are structured in the page tree, HMENU also allows you to use the .special property to create special menus. These special menus take characteristics of special menu types into account.

Properties

1, 2, 3, ...

Property:

1, 2, 3, ...

Data type

menu object

Default

(no menu)

Description

For every menu level, that should be rendered, an according entry must exist. It defines the menu object that should render the menu items on the according level. 1 is the first level, 2 is the second level, 3 is the third level and so on.

The property "1" is required!

The entry 1 for the first level always must exist. All other levels only will be generated when they are configured.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
temp.sidemenu = HMENU
temp.sidemenu.1 = TMENU
temp.sidemenu.1 {
  # Configuration of that TMENU here...
}
temp.sidemenu.2 = TMENU
temp.sidemenu.2 {
  # Configuration of that TMENU here...
}
temp.sidemenu.3 = TMENU
temp.sidemenu.3 {
  # Configuration of that TMENU here...
}

This creates a menu with up to three levels: Each TMENU level can hold a different menu configuration.

TYPO3 offers a variety of menu objects.

cache_period

Property

cache_period

Data type

integer

Description

The number of seconds a menu may remain in cache. If this value is not set, the first available value of the following will be used:

  1. cache_timeout of the current page

  2. config.cache_period defined globally

  3. 86400 (= 1 day)

cache

Property

cache

Data type

cache

Description

Stores the rendered content into the caching framework and reads it from there. This allows you to reuse this content on different pages without prior rendering. The presence of cache.key will trigger this feature. See cache function description for details.

entryLevel

Property

entryLevel

Data type

integer /stdWrap

Default

0

Description

Defines at which level in the rootLine the menu should start.

Default is "0" which gives us a menu of the very first pages on the site.

If the value is < 0, entryLevel is chosen from "behind" in the rootLine. Thus "-1" is a menu with items from the outermost level, "-2" is the level before the outermost...

Note: entryLevel does not show a menu of a certain level of pages (use special = directory for that) but it means that it will start to be visible from that level on.

So, for example if you build a simple "sitemap" menu like this one:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 = HMENU
page.10 {
  entryLevel = 4
  1 = TMENU
  1.wrap = <ul> | </ul>
  1.NO.wrapItemAndSub = <li> | </li>
  1.expAll = 1
  2 < .1
  3 < .2
  4 < .3
  5 < .4
  6 < .5
  7 < .6
}

it will start to be visible from the 4th level (and will contain only the subpages from that level). Please note also that this affects also the menu generated with MenuProcessor. Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
page.10 {
   dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
    10 {
       special = list
       special.value.field = pages
       levels = 7
       entryLevel = 4
       as = menu
       expandAll = 1
       titleField = nav_title // title
    }
  }
}

special

Property

special

Data type

"directory" / "list" / "updated" / "rootline" / "browse" / "keywords" / "categories" / "language" / "userfunction"

Description

Lets you define special types of menus.

See the section about the .special property!

special.value

Property

special.value

Data type

list of page-uid's /stdWrap

Description

List of page uid's to use for the special menu. What they are used for depends on the menu type as defined by ".special"; see the section about the .special property!

minItems

Property

minItems

Data type

integer /stdWrap

Description

The minimum number of items in the menu. If the number of pages does not reach this level, a dummy-page with the title "..." and uid=[currentpage_id] is inserted.

Note: Affects all sub menus as well. To set the value for each menu level individually, set the properties in the menu objects (see "Common properties" table).

maxItems

Property

maxItems

Data type

integer /stdWrap

Description

The maximum number of items in the menu. Additional items will be ignored.

Note: Affects all sub menus as well. (See "minItems" for a notice.)

begin

Property

begin

Data type

integer /stdWrap +calc

Description

The first item in the menu.

Example:

This results in a menu, where the first two items are skipped starting with item number 3:

EXT:site_package/Configuration/TypoScript/setup.typoscript
begin = 3

Note: Affects all sub menus as well. (See "minItems" for a notice.)

excludeUidList

Property

excludeUidList

Data type

list of integers /stdWrap

Description

This is a list of page uid's to exclude when the select statement is done. Comma-separated. You may add "current" to the list to exclude the current page.

Example:

The pages with these uid-numbers will not be within the menu! Additionally the current page is always excluded too.

EXT:site_package/Configuration/TypoScript/setup.typoscript
excludeUidList = 34,2,current

excludeDoktypes

Property

excludeDoktypes

Data type

list of integers

Default

6,254

Description

Enter the list of page document types (doktype) to exclude from menus. By default pages that are "backend user access only" (6) or "folder" (254) are excluded.

includeNotInMenu

Property

includeNotInMenu

Data type

boolean /stdWrap

Description

If set, pages with the checkbox "Page enabled in menus" disabled will still be included in menus.

alwaysActivePIDlist

Property

alwaysActivePIDlist

Data type

list of integers /stdWrap

Description

This is a list of page UID numbers that will always be regarded as active menu items and thereby automatically opened regardless of the rootline.

protectLvar

Property

protectLvar

Data type

boolean / keyword

Description

If set, then for each page in the menu it will be checked if an Alternative Page Language record for the language defined in "config.sys_language_uid" exists for the page. If that is not the case and the pages "Localization settings" have the "Hide page if no translation for current language exists" flag set, then the menu item will link to a non accessible page that will yield an error page to the user. Setting this option will prevent that situation by simply adding "&L=0" for such pages, meaning that they will switch to the default language rather than keeping the current language.

The check is only carried out if a translation is requested ("config.sys_language_uid" is not zero).

Keyword: "all"

When set to "all" the same check is carried out but it will not look if "Hide page if no translation for current language exists" is set - it always reverts to default language if no translation is found.

For these options to make sense, they should only be used when "config.sys_language_mode" is not set to "content_fallback".

addQueryString

Property

addQueryString

Data type

string

Description

see typolink.addQueryString

Note: This works only for special=language.

if

Property

if

Data type

->if

Description

If "if" returns false, the menu is not generated.

wrap

Property

wrap

Data type

wrap /stdWrap

Description

Wrap for the HMENU.

stdWrap

Property

stdWrap

Data type

->stdWrap

Description

(Executed after ".wrap".)

[tsref:(cObject).HMENU]

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
temp.sidemenu = HMENU
temp.sidemenu.entryLevel = 1
temp.sidemenu.1 = TMENU
temp.sidemenu.1 {
  target = page
  NO.afterImg = media/bullets/dots2.gif |*||*| _
  NO.afterImgTagParams = style="margin: 0px 20px;"
  NO.linkWrap = {$fontTag}
  NO.ATagBeforeWrap = 1

  ACT < .NO
  ACT = 1
  ACT.linkWrap = <b>{$fontTag}</b>
}

The .special property

This property makes it possible to create menus that are not strictly reflecting the current page-structure, but rather creating a breadcrumb menu, a language menu or menus with links to pages like next/previous, last modified, all subpages of a page and so on.

Note

.entryLevel generally is not supported together with the .special property! The only exception is special = keywords.

Also be aware that this property selects pages for the first level in the menu. Submenus by menuObjects 2+ will be created as usual.

See the following menus types based on the special property: