Categories HMENU

Makes a menu of pages belonging to one or more categories. If a page belongs to several of the selected categories, it will appear only once. By default pages are unsorted.

Each in the resulting array of pages gets an additional entry with key _categories containing the list of categories the page belongs to, as a comma-separated list of uid's. It can be accessed with field or data. like any other field.

Properties

special.value

special.value
Type
list of categories / stdWrap

Comma-separated list of categories UID's.

Example: List pages in categories with UID 1 and 2

20 = HMENU
20 {
    special = categories
    special.value = 1,2
    1 = TMENU
    1.NO {
        // ...
    }
}
Copied!

special.relation

special.relation
Type
string / stdWrap
Default
categories

Name of the categories-relation field to use for building the list of categorized pages, as there can be several such fields on a given table.

special.sorting

special.sorting
Type
string / stdWrap

Which field from the pages table should be used for sorting. Language overlays are taken into account, so alphabetical sorting on the "title" field, for example, will work.

If an unknown field is defined, the pages will not be sorted.

special.order

special.order
Type
asc or desc / stdWrap
Default
asc

Order in which the pages should be ordered, ascending or descending. Should be asc or desc, case-insensitive. Will default to asc in case of invalid value.

Example: Menu of pages in a certain category

The content element Menu > Categorized pages provided by the system extension EXT:fluid_styled_content is configured with a MenuProcessor which is based on the options of the HMENU and provides all its properties:

EXT:fluid_styled_content/Configuration/TypoScript/ContentElement/MenuCategorizedPages.typoscript
# Pages for selected categories:
# ...
#
# CType: menu_categorized_pages

tt_content.menu_categorized_pages =< lib.contentElement
tt_content.menu_categorized_pages {
    templateName = MenuCategorizedPages
    dataProcessing {
        10 = menu
        10 {
            special = categories
            special {
                value.field = selected_categories
                relation.field = category_field
                sorting = title
                order = asc
            }
            dataProcessing {
                10 = files
                10 {
                    references.fieldName = media
                }
            }
        }
    }
}
Copied!

The following Fluid template can be used to style the menu:

EXT:fluid_styled_content/Resources/Private/Templates/MenuCategorizedPages.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="Main">

    <f:if condition="{menu}">
        <ul>
            <f:for each="{menu}" as="page">
                <li>
                    <a href="{page.link}"{f:if(condition: page.target, then: ' target="{page.target}"')}{f:if(condition: page.current, then: ' aria-current="page"')} title="{page.title}">
                        <span>{page.title}</span>
                    </a>
                </li>
            </f:for>
        </ul>
    </f:if>

</f:section>
</html>
Copied!