Skip to content

Commit ac07ee2

Browse files
[Backport 13.4] [TASK] Use Browse menus with Data processors (#1498)
* [TASK] Use Browse menus with Data processors Remove HMENU usage and refer to older versions for that. Releases: main, 13.4 * [TASK] Use Browse menus with Data processors Remove HMENU usage and refer to older versions for that. Releases: main, 13.4 --------- Co-authored-by: lina.wolf <[email protected]>
1 parent d4690af commit ac07ee2

File tree

4 files changed

+111
-225
lines changed

4 files changed

+111
-225
lines changed
Lines changed: 102 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
:navigation-title: Browse
22
.. include:: /Includes.rst.txt
33
.. _hmenu-special-browse:
4+
.. _MenuProcessor-special-browse:
45

5-
================================
6-
Browse - previous and next links
7-
================================
6+
===========================================
7+
Browse navigation - previous and next links
8+
===========================================
89

9-
This menu contains pages which give your user the possibility to
10+
This data processor provides pages which give your reader the possibility to
1011
browse to the previous page, to the next page, to a page with the
11-
table of contents and so on. The menu is built of items given by a
12-
list from the property ".items".
12+
table of contents and so on.
13+
14+
.. tip::
15+
In older TypoScript browser menus were created using the `HMENU` object.
16+
This still works for backward compatibility reasons. We recommend to only use
17+
data processors for newly created menus.
18+
19+
See :ref:`TYPO3 11, Browse navigation <t3tsref/:hmenu-special-browse>` for
20+
examples how this was done.
1321

1422
.. attention::
15-
Mount pages are *not* supported!
23+
Mount pages are *not* supported!
1624

1725
.. contents::
18-
:local:
26+
:local:
1927

20-
.. _hmenu-special-browse-properties:
28+
.. _MenuProcessor-special-browse-properties:
2129

2230
Properties
2331
==========
@@ -27,193 +35,88 @@ Properties
2735
:type:
2836
:Default:
2937

30-
.. _hmenu-special-browse-value:
31-
32-
.. confval:: special.value
33-
:name: hmenu-browse-special-value
34-
:type: integer /:ref:`stdWrap <stdwrap>`
35-
:Default: current page ID
36-
37-
The default value can be overridden with a different page ID as starting
38-
point for the menu in some rare use cases.
39-
40-
41-
.. _hmenu-special-browse-items:
42-
43-
.. confval:: special.items
44-
:name: hmenu-browse-special-items
45-
:type: list of item names separated by `|`
46-
:Default: Current page ID
47-
48-
Each element in the list (separated by `|`) is either a reserved item
49-
name (see list) with a predefined function, or a user-defined name
50-
which you can assign a link to any page. Note that the current page
51-
cannot be the root-page of a site.
52-
53-
.. rubric:: Reserved item names:
54-
55-
`next` / `prev`
56-
Links to the next page / the previous page.
57-
Next and previous pages are from the same "pid" as the current page id
58-
(or "value") - that is the next item in a menu with the current page.
59-
Also referred to as current level.
60-
61-
If :confval:`hmenu-browse-special-items-prevnextToSection` is set then
62-
`next` / `prev` will link to the first
63-
page of the next section / to the last page of the previous section,
64-
too.
65-
66-
`nextsection` / `prevsection`
67-
Links to the next section / the
68-
previous section. A section is defined as the subpages of a page on
69-
the same level as the parent (pid) page of the current page. Will not
70-
work if the parent page of the current page is the root page of the
71-
site.
72-
73-
.. figure:: /Images/ManualScreenshots/FrontendOutput/Hmenu/ContentObjectsHmenuSpecialBrowse.png
74-
:alt: Example for the usage of the property "items".
75-
76-
`nextsection_last` / `prevsection_last`
77-
Where `nextsection` / `prevsection` links to the first page in a section, these
78-
link to the last page. If there is only one page in the section that
79-
will be both first and last. Will not work if the parent page of the
80-
current page is the root page of the site.
81-
82-
`first` / `last`
83-
First / last page on the current level. If
84-
there is only one page on the current level that page will be both
85-
first and last.
86-
87-
`up`
88-
Links to the parent (pid) page of the current page (up 1
89-
level). Will always be available.
90-
91-
`index`
92-
Links to the parent of the parent page of the current
93-
page(up 2 levels). May not be available, if that page is out of the
94-
root line.
95-
96-
97-
.. _hmenu-special-browse-items-example:
98-
99-
Example: Display different types of browse links
100-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101-
102-
If id = 20 is the current page then:
103-
104-
21 = prev and first, 19 = next, 18 = last, 17 = up, 1 = index, 10 =
105-
nextsection, 11 = nextsection\_last
106-
107-
prevsection and prevsection\_last are not present because id = 3 has
108-
no subpages!
109-
110-
**TypoScript (only "browse"-part, needs also TMENU):**
111-
112-
.. code-block:: typoscript
113-
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript
114-
115-
xxx = HMENU
116-
xxx.special = browse
117-
xxx.special {
118-
items = index|up|next|prev
119-
items.prevnextToSection = 1
120-
index.target = _blank
121-
index.fields.title = INDEX
122-
index.uid = 8
123-
}
124-
125-
.. _hmenu-special-browse-prevnexttosection:
126-
127-
special.items.prevnextToSection
128-
--------------------------------
129-
130-
.. confval:: special.items.prevnextToSection
131-
:name: hmenu-browse-special-items-prevnextToSection
132-
:type: boolean
133-
:Default: false
134-
135-
If set, the `prev` and `next` navigation will jump to the next section
136-
when it reaches the end of pages in the current section. That way
137-
`prev` and `next` will also link to the first page of the next section
138-
/ to the last page of the previous section.
139-
140-
141-
.. _hmenu-special-browse-target:
142-
143-
special.[itemname].target
144-
--------------------------
145-
146-
.. confval:: special.[itemname].target
147-
:name: hmenu-browse-special-itemname-target
148-
:type: string
149-
150-
Optional or alternative target of the item.
151-
152-
.. _hmenu-special-browse-uid:
153-
154-
special.[itemname].uid
155-
-----------------------
156-
157-
.. confval:: special.[itemname].uid
158-
:name: hmenu-browse-special-itemname-uid
159-
:type: integer (UID of page)
160-
161-
Optional or alternative page UID to link to.
162-
163-
.. _hmenu-special-browse-fields:
164-
165-
special.[itemname].fields.[field name]
166-
---------------------------------------
167-
168-
.. confval:: special.[itemname].fields.[field name]
169-
:name: hmenu-browse-special-itemname-fields
170-
:type: string
171-
172-
Use the provided string as linked text instead of the pages title.
173-
174-
175-
.. _hmenu-special-browse-fields-example:
176-
177-
Example: Use "back" as text on the `prev` link
178-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179-
180-
This gives the link to the previous page the linked text "« back":
181-
182-
.. code-block:: typoscript
183-
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript
184-
185-
prev.fields.title = « back
186-
187-
188-
.. _hmenu-special-browser-excludenosearchpages:
189-
190-
special.excludeNoSearchPages
191-
-----------------------------
192-
193-
194-
.. confval:: special.excludeNoSearchPages
195-
:name: hmenu-browse-special-excludeNoSearchPages
196-
:type: boolean
197-
:Default: false
198-
199-
If set, pages marked with the `no search` checkbox will be excluded from the menu.
200-
201-
.. _hmenu-special-browser-example:
202-
203-
Example: Pagination with rel="next" and rel="prev"
204-
==================================================
205-
206-
The following snippet uses a :ref:`HMENU <cobj-hmenu>` with
207-
:typoscript:`special = browse` to display links like the following:
208-
209-
.. code-block:: html
210-
:caption: Example HTML output
211-
212-
<link rel="prev" href="http://www.example.org/page1" />
213-
<link rel="next" href="http://www.example.org/page2" />
214-
215-
The menu excludes pages with the flag :guilabel:`Include in Search` removed
216-
and jumps to the next section when the last of subpages is reached.
217-
218-
.. literalinclude:: _code-snippets/_RelPrevNextMenu.typoscript
219-
:caption: EXT:site_package/Configuration/TypoScript/Seo/Setup/RelPrevNextMenu.typoscript
38+
.. confval:: special.value
39+
:name: hmenu-browse-special-value
40+
:type: integer /:ref:`stdWrap <stdwrap>`
41+
:Default: current page ID
42+
43+
The default value can be overridden with a different page ID as starting
44+
point for the menu in some rare use cases.
45+
46+
.. confval:: special.items
47+
:name: hmenu-browse-special-items
48+
:type: list of item names separated by `|`
49+
:Required:
50+
51+
A list, separated by pipes `|`, containing the following item types:
52+
53+
`next` / `prev`
54+
Links to the next page / the previous page.
55+
Next and previous pages are from the same "pid" as the current page id
56+
(or "value") - that is the next item in a menu with the current page.
57+
Also referred to as current level.
58+
59+
If :confval:`hmenu-browse-special-items-prevnextToSection` is set then
60+
`next` / `prev` will link to the first
61+
page of the next section / to the last page of the previous section,
62+
too.
63+
64+
`nextsection` / `prevsection`
65+
Links to the next section / the
66+
previous section. A section is defined as the subpages of a page on
67+
the same level as the parent (pid) page of the current page. Will not
68+
work if the parent page of the current page is the root page of the
69+
site.
70+
71+
`nextsection_last` / `prevsection_last`
72+
Where `nextsection` / `prevsection` links to the first page in a section, these
73+
link to the last page. If there is only one page in the section that
74+
will be both first and last. Will not work if the parent page of the
75+
current page is the root page of the site.
76+
77+
`first` / `last`
78+
First / last page on the current level. If
79+
there is only one page on the current level that page will be both
80+
first and last.
81+
82+
`up`
83+
Links to the parent (pid) page of the current page (up 1
84+
level). Will always be available.
85+
86+
`index`
87+
Links to the parent of the parent page of the current
88+
page(up 2 levels). May not be available, if that page is out of the
89+
root line.
90+
91+
.. confval:: special.items.prevnextToSection
92+
:name: hmenu-browse-special-items-prevnextToSection
93+
:type: boolean
94+
:Default: false
95+
96+
If set, the `prev` and `next` navigation will jump to the next section
97+
when it reaches the end of pages in the current section. That way
98+
`prev` and `next` will also link to the first page of the next section
99+
/ to the last page of the previous section.
100+
101+
.. confval:: special.excludeNoSearchPages
102+
:name: hmenu-browse-special-excludeNoSearchPages
103+
:type: boolean
104+
:Default: false
105+
106+
If set, pages marked with the `no search` checkbox will be excluded from the menu.
107+
108+
.. _MenuProcessor-special-browse-example:
109+
110+
Example: Display a browse navigation
111+
====================================
112+
113+
The menu data processor with `special = browse` returns the found items as an
114+
array. The items in this array contain no information about what kind of item
115+
(previous, next, up, etc) they are. We therefore recommend to only use one
116+
item kind per data processor:
117+
118+
.. literalinclude:: _code-snippets/_BrowseNavigation.typoscript
119+
:caption: config/sites/mySite/setup.typoscript
120+
121+
The result of each data processor can then be used, assuming that the result is
122+
the first item of the array saved into the database.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<f:if condition="{prevNavigation.0}">
2+
<a href="{prevNavigation.0.link}">&lt;- {prevNavigation.0.title}</a>
3+
</f:if>
4+
<f:if condition="{nextNavigation.0}">
5+
<a href="{nextNavigation.0.link}">{nextNavigation.0.title} -&gt;</a>
6+
</f:if>
7+
<f:if condition="{upNavigation.0}">
8+
<a href="{upNavigation.0.link}">{upNavigation.0.title}</a>
9+
</f:if>

Documentation/DataProcessing/MenuProcessor/_code-snippets/_RelPrevNextMenu.typoscript

Lines changed: 0 additions & 26 deletions
This file was deleted.
-2.18 KB
Binary file not shown.

0 commit comments

Comments
 (0)