De:TSref/HMENU
From TYPO3Wiki
| TypoScript Referenz - HMENU |
|
||||
This page is document in progress. TypoScript (Liste TypoScript)
HMENU bildet die Basis für hierarchische Menüs. Es wird in der Regel dazu verwendet die Navigationsmenüs aufzubauen.
Dieses Objekt wird für jedes Menü benötigt. Es werden die globalen Eigenschaften des Menüs festgelegt. Jede Menü Ebene kann durch unterschiedliche MenuItems implementiert werden. Für besondere Funktionen gibt es die Option .special die Besonderheiten bei der Implementierung von Menüs berücksichtigt.
Contents |
[edit] Allgemeine Menü Konfiguration
Ähnlich wie von den COA gibt es die Möglichkeit anhand von Zahlen unterschiedliche Menü-Ebenen zu implementieren. Allerdings fängt hier die erste Menü-Ebene mit 1 an und Lücken dazwischen sind nicht erlaubt.
Das HMENU ist das übergeordnete Objekt, das die relevanten Daten lädt und für jede Ebene das definierte Menü-Objekt erzeugt. So kann auf dem ersten Menü-Level ein Textmenü (TMENU erzeugt werden, auf der zweiten Ebene wird dann ein graphisches Menü GMENU erzeugt und auf der dritten wieder ein Textmenü.
lib.menu = HMENU # Grafisches Menü auf der ersten Ebene lib.menu.1 = GMENU # Textmenü auf Ebene zwei und drei lib.menu.2 = TMENU lib.menu.3 = TMENU
Neben der ganz normalen Menü-Funktion die einfach den Seitenbaum ab einem bestimten Level (entryLevel) darstellt, gibt es noch unterschiedliche Special-Menüs. Die Daten werden auf eine andere Art erzeugt - die Darstellung wird allerdings wieder so definiert wie bei der Seitenbaum Darstellung.
Innerhalb jeder Menü-Ebene gibt es unterschiedliche Menü Zustände. Ein Menü kann aktiviert sein, es kann Unterseiten enthalten etc. Die möglichen Varianten können auch von dem Menü-Typ der Ebene abhängig sein. So definiert z.B. das grafische Menü (GMENU) einen zusätzlichen Zustand "RO".
Es gibt allgemeine Eigenschaften die bei allen (wenn nicht anders angegeben) Menü-Typen definiert sind und dann nochmal für jeden Menütyp spezielle in dem Fall relevante Menütypen.
- HMENU (diese Seite) bezieht sich auf die betroffenen Daten
- Allgemeine Menü-Eigenschaften pro Menü-Ebene http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/1/
- Menü-Zustände http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/2/
- .sectionIndex http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/3/
- GMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/4/
- GMENU_LAYERS, TMENU_LAYERS http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/5/
- GMENU_FOLDOUT http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/6/
- TMENU
- TMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/8/
- IMGMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/9/
- IMGMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/10/
- JSMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/11/
- JSMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/10/12/
[edit] Referenz
| Eigenschaft: | Datentyp: | Beschreibung: | Default: |
| (1 / 2 / 3 /...) | menuObj | Für jede Menü-Ebene die abgebildet werden soll, muss ein entsprechender Eintrag existieren. Es können unterschiedliche Menü-Objekte für das Rendering verwendet werden.
1 ist die erste zu erzeugende Menü-Ebene, 2 die zweite, 3 die dritte ... Die 1 muss immer existieren, alle weiteren Ebenen werden nur erzeugt, wenn die Ebene darüber auch existiert. Wenn die zweite Ebene nicht definiert ist, wird auch die dritte nicht mehr erzeugt.
# Beispiel: temp.sidemenu = HMENU temp.sidemenu.1 = GMENU temp.sidemenu.2 = TMENU temp.sidemenu.3 = TMENU
| (no menu) |
| entryLevel | int | Definiert, in welcher Ebene der rootline das Menü beginnen soll.
Default ist "0", und generiert ein Menü der ersten Seitenebene. Wenn der Wert negativ ist, wird das entryLevel "hinter" der rootline auswählen. "-1" wird ein Menü von der äußeren Seite aus generieren. | 0 |
| special | "directory" / "list" / "updated" / "browse" / "rootline" / "keywords" / language | (Weiter unten in separater Tabelle erläutert) | |
| special.value | Liste von page-uid's /stdWrap | (siehe oben) | |
| minItems | int | Mindestanzahl von Elementen im Menü. Sollte die Zahl der Seiten nicht ausreichen, werden "dummy" Seiten mit dem Titel "..." und der uid=[currentpage_id] erzeugt.
Info: Wirkt auch auf alle Submenüs. Um den Wert für die Menüebenen einzeln einzustellen muss der Wert in den Menüobjekten selbst gesetzt werden. (see Common properties table). | |
| maxItems | int | Maximale Anzahl von Elementen im Menü. Darüberhinausgehende Seiten werden ignoriert.
Info: Wirkt auch auf alle Submenüs. (siehe "minItems") | |
| begin | int +calc | Erstes Element im Menü.
# Beispiel: Dies erzeugt ein Menü, welches die ersten beiden Elemente auslässt und direkt mit dem dritten Element beginnt: begin = 3 Info: Wirkt auch auf alle Submenüs. (siehe "minItems") | |
| excludeUidList | Liste von integers | Kommagetrennte Liste von Seiten-uids welche beim SELECT statement bereits ignoriert werden. Das Schlüsselwort "current" exkludiert die aktuelle Seite.
# Beispiel: Sowohl die Seiten mit den uid 2 und 34 werden nicht im Menü erscheinen, als auch die jetzige Seite nicht. excludeUidList = 34,2,current | |
| excludeDoktypes | Liste von integers | Kommagetrennte Liste von Seitendokument-Typen (doktype) welche nicht im Menü erscheinen werden. Default sind die doktypes 5 ("im Menü verbergen") und 6 ("Backend Benutzerbereich"). | 5,6 |
| includeNotInMenu | boolean | Ist dieser Wert wahr, werden auch Seiten ins Menü aufgenommen, die als "im Menü verbergen" definiert sind.
Der Wert "5" wird einfach von der Eigenschaft "excludeDoktypes" entfernt. (siehe oben). | |
| alwaysActivePIDlist | Liste von integers | Kommagetrennte Liste von Seiten-uids, die immer als "active" gehandhabt werden sollen. Diese Seiten sind immer automatisch aufgeklappt, rootline egal. | |
| protectLvar | boolean / keyword |
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" (typically defined via &L) 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 | see typolink.addQueryString | Info: Wirkt nur bei special=language. | |
| if | ->if | Wenn "if" falsch ergibt, wird das Menü nicht generiert. | |
| wrap | wrap | ||
| stdWrap | ->stdWrap |
[tsref:(cObject).HMENU]
# Beispiel:
temp.sidemenu = HMENU
temp.sidemenu.entryLevel = 1
temp.sidemenu.stdWrap.wrap = <div class="hmenu">|</div>
temp.sidemenu.1 = TMENU
temp.sidemenu.1 {
target = page
NO.afterImg = media/bullets/dots2.gif |*||*| _
NO.afterImgTagParams = hspace="4"
NO.linkWrap = {$fontTag}
NO.ATagBeforeWrap = 1
ACT < .NO
ACT = 1
ACT.linkWrap = {$fontTag}
}
[edit] Menü Einträge / menuitems
Es gibt unterschiedliche Möglichkeiten Menüs darzustellen. Als einfache Textmenüs, dynamische Javascript Menüs oder Grafische Menüs. Das Objekt HMENU ist das Basis Objekt das für jede Menü-Ebene die benötigten Daten bereitstellt.
# grundsätzliche Skizze der Struktur # Wir definieren ein Menü MARKER = HMENU # die erste Ebene wird als Textmenü gerendert MARKER.1 = TMENU # In der ersten Ebene wird das aktuelle Menüelement (menuitem) besonders behandelt # Welche Optionen möglich sind, wird via TMENUITEM definiert. MARKER.1.ACT = 1 # die zweite Menüebene wird als grafisches Menü gerendert MARKER.2 = GMENU # In der zweiten Menüe wird das angeklickte Element besonders behandelt # Der Unterschied zwischen ACT und CUR liegt in der Vererbung. # Die aktuell angelickte Seite ist CUR, alle Seiten die in der Rootline liegen, # sind dann ACT MARKER.2.CUR = 1
Links: http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/8/11/
Allgemeine Optionen für die jeweilige Menü-Ebene (TMENU, GMENU usw.). MENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/1/ und .sectionIndex http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/3/
Allgemeine Optionen für die jeweiligen Menü-Elemente (menuitems: ACT, CUR, NO usw.) http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/2/
GMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/4/
GMENU_LAYERS - TMENU_LAYERS http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/5/
GMENU_FOLDOUT http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/6/
TMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/7/
TMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/8/
IMGMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/9/
IMGMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/10/
JSMENU http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/11/
JSMENUITEM http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/10/12/
[edit] Spezielle Menüs
Die Eigenschaft .special
Mit dieser Eigenschaft ist es möglich, Menüs zu erzeugen, die nicht einfach nur die Seitenhierarchie abbilden. So sind u.A. Menüs möglich, die alle Seiten innerhalb einer Seite auflisten, oder Menüs mit "vorherige/nächste" oder die Liste der zuletzt bearbeiteten Seiten.
Info: Wenn die .special-Eigenschaft verwendet wird, darf .entryLevel nicht gesetzt werden. Ausserdem wird die Eigenschaft nur auf die erste Ebene der generierten Seiten wirken, Untermenüs (2+) werden als normale Menüs erstellt.
Für .special.value gilt immer die stdWrap-Eigenschaft!
Die Eigenschaften folgend zusammengefasst:
| Typ: | Beschreibung: | Default: |
| directory | Wird ein Menü aus allen Seiten erzeugen, die in den Seiten (pid=13 und pid=37) gefunden werden.
20 = HMENU 20.special = directory 20.special.value = 13, 37 Sollte .value nicht gesetzt sein, wird als default die aktuelle Seite verwendet. Unterstützt Mount Pages. | |
| list | Wird ein Menü aus den beiden Seiten (pid= 13 und pid=37) erzeugen.
20 = HMENU 20.special = list 20.special.value = 13, 37 Sollte .value nicht gesetzt sein, wird als default die .entryLevel uid verwendet. Unterstützt Mount Pages. | |
| updated | Wird ein Menü aus den zuletzt geänderten Seiten von den Branches der Startseiten (pid=13 und pid=37) erzeugen. Als Kriterium wird das Tabellenfeld "tstamp" verwendet (default ist SYS_LASTCHANGED) und die Rekursionstiefe beträgt 2. Maximal 8 Seiten werden gezeigt und diese müssen innerhalb der letzten drei Tage (3600*24*3) geändert worden sein:
20 = HMENU
20.special = updated
20.special.value = 13, 37
20.special {
mode = tstamp
depth = 2
maxAge = 3600*24*3
limit = 8
}
Als default wird immer anhand des Felds, welches in "mode" definiert wird, rückwärts sortiert (desc). Es kann aber das "alternativeSortingField" (für das Menüobjekt) gesetzt werden, was die andere Sortierung ausser Kraft setzt. Die Eigenschaften "mode", "depth", "maxAge" und "limit" werden nur mit special="updated" verwendet. mode: Definiert, welches Feld der Seitentabelle verwendet wird. Default: "SYS_LASTCHANGED" (welches automatisch auf die jüngste tstamp gesetzt wird, wenn eine neue Seite oder ein Element innerhalb angelegt wird). "manual" oder "lastUpdated" wird das Feld "lastUpdated" auslesen, welches manuell in den Seiteneigenschaften bearbeitet wird. "tstamp" wird das Zeitstempelfeld "tstamp" auslesen, welches gesetzt wird, wenn die Seitendatensatz bearbeitet wird. "crdate" wird das Feld "crdate" des Seitendatensatzes auslesen. starttime wird das Feld "starttime" auslesen. Felder deren Wert 0 ist, werden nicht angezeigt werden. depth: (int) Rekursionstiefe. Werte von 1-20 sind möglich, wobei 1 nur die Start-ID zulässt, 2 die Start-ID + erste Ebene. Default ist 20. Info: "depth" ist relativ zu "beginAtLevel". beginAtLevel: (int) Startebene für die Seitenbäume die auf .value und .depth basierend erzeugt werden. Default ist 0 und ist die Start-ID. 1 beginnt mit der ersten Ebene der Unterseiten, 2 beginnt mit der zweiten Ebene der Unterseiten. Der Wert "depth" ist relativ zu "beginAtLevel". maxAge: (int) Sekunden +calc. Seiten, deren Änderungsdatum älter als die jetzige Zeit minus der gesetzten Sekunden sind, werden nicht mehr gezeigt. Wird nicht im Default verwendet (not used). Für die Werte können die primitiven Rechenoperationen ( + - * / ) verwendet werden (3600*24*3 ist also möglich). limit: (int) Maximale Anzahl der Menüelemente. Default ist 10, Maximum ist 100. excludeNoSearchPages: Boolean. Ist dieser Wert wahr, werden die Seiten welche "nicht suchen" gesetzt haben, nicht in die Menüs mit aufgenommen. Unterstützt Mount Pages. | |
| rootline | Erzeugt ein Menü mit den Seiten der "rootline" (siehe weiter oben). So genannte Breadcrumb / Klickpfad Menüs sind hiermit möglich.
.range = [begin-level] | [end-level] (genau so, wie .entryLevel für HMENU Objekte gesetzt wird) .target_[0-x] Ziel(e)
page.2 = HMENU page.2.special = rootline page.2.special.range = 1|-2 page.2.special.targets.3 = page page.2.1 = TMENU page.2.1.target = _top page.2.1.wrap = <HR> | <HR> page.2.1.NO { linkWrap = | > } ... erzeugt ein Menü wie dieses: Seite Ebene 1 > Seite Ebene 2 > Seite Ebene 3 > Seite Ebene 4 > Dieses Menü beginnt in Ebene 1 und verlinkt die aktuelle Seite nicht (-2 ist die Ebene davor). Alle Seiten auf Ebene 3 werden "page" als .target haben, Seiten auf anderen Ebenen "_top". Unterstützt Mount Pages. | |
| browse | ") is either a reserved itemname (see list) with a predefined function or a userdefined name which you can assign a link to any page. Note that the current page cannot be the root-page of a site.
Support for Mount Pages: No! Main properties: .items ( "|" separated list of "itemnames") .[itemnames].target (target) - optional/alternative target of the item .[itemnames].uid (uid of page) - optional/alternative page-uid to link to .[itemnames].fields.[fieldname] (string) - override field "fieldname" in pagerecord. .items.prevnextToSection (boolean) - if set, the "prev" and "next" navigation will jump to the next section when it reaches the end of pages in the current section .value (page-uid) - default is current page id. Seldomly you might want to override this value with another page-uid which will then act as the basepoint for the menu and the predefined items. Ordering is by default done in reverse order (desc) with the field specified by mode , but setting alternativeSortingField for the menu object (eg GMENU, see later) will override that. Reserved itemnames: next / prev : links to next page / previous page. Next and previous pages are from the same "pid" as the current page id (or "value") - that is the next item in a menu with the current page. Also referred to as current level. If ".prevnextToSection" is set then next/prev will link to the first page of next section / last page of previous section. nextsection / prevsection : links to next section / previous section. A section is defined as the subpages of a page on the same level as the parent (pid) page of the current page. Will not work if parent page of current page is the root page of the site. nextsection_last | prevsection_last: Where nextsection/prevsection links to the first page in a section, these links to the last pages. If there is only one page in the section that will be both first and last. Will not work if parent page of current page is the root page of the site. first / last : First / Last page on current level. If there is only one page on the current level that page will be both first and last. up : Links to the parent (pid) page of the current page. (up 1 level) Will always be available index : Links to the parent of the parent page of the current page (up 2 levels). May not be available if that page is out of the rootline. Examples: If id=20 is current page then: 21= prev and first, 19 = next, 18 = last, 17 = up, 1=index, 10 = nextsection, 11 = nextsection_last prevsection and prevsection_last is not present because id=3 has no subpages! TypoScript (only "browse"-part, needs also TMENU/GMENU): xxx = HMENU
xxx.special = browse
xxx.special {
items = index|up|next|prev
items.prevnextToSection = 1
index.target = _blank
index.fields.title = INDEX
index.uid = 8
}
.items ( "|" separated list of "itemnames") .[itemnames].target (target) - optional/alternative target of the item .[itemnames].uid (uid of page) - optional/alternative page-uid to link to .[itemnames].fields.[fieldname] (string) - override field "fieldname" in pagerecord. .items.prevnextToSection (boolean) - if set, the "prev" and "next" navigation will jump to the next section when it reaches the end of pages in the current section .value (page-uid) - default is current page id. Seldomly you might want to override this value with another page-uid which will then act as the basepoint for the menu and the predefined items. Ordering is by default done in reverse order (desc) with the field specified by mode , but setting alternativeSortingField for the menu object (eg GMENU, see later) will override that. Reserved itemnames: next / prev : links to next page / previous page. Next and previous pages are from the same "pid" as the current page id (or "value") - that is the next item in a menu with the current page. Also referred to as current level. If ".prevnextToSection" is set then next/prev will link to the first page of next section / last page of previous section. nextsection / prevsection : links to next section / previous section. A section is defined as the subpages of a page on the same level as the parent (pid) page of the current page. Will not work if parent page of current page is the root page of the site. nextsection_last | prevsection_last: Where nextsection/prevsection links to the first page in a section, these links to the last pages. If there is only one page in the section that will be both first and last. Will not work if parent page of current page is the root page of the site. first / last : First / Last page on current level. If there is only one page on the current level that page will be both first and last. up : Links to the parent (pid) page of the current page. (up 1 level) Will always be available index : Links to the parent of the parent page of the current page (up 2 levels). May not be available if that page is out of the rootline. Examples: If id=20 is current page then: 21= prev and first, 19 = next, 18 = last, 17 = up, 1=index, 10 = nextsection, 11 = nextsection_last prevsection and prevsection_last is not present because id=3 has no subpages! TypoScript (only "browse"-part, needs also TMENU/GMENU): xxx = HMENU
xxx.special = browse
xxx.special {
items = index|up|next|prev
items.prevnextToSection = 1
index.target = _blank
index.fields.title = INDEX
index.uid = 8
}
| |
| keywords | Makes a menu of pages with one or more keywords also found on the current page.
.value = page for which keywords to find similar pages. .mode: Which field in the pages-table to use for sorting. Default is "SYS_LASTCHANGED" (which is updated when a page is generated to the youngest tstamp of the records on the page), "manual" or lastUpdated will use the field "lastUpdated" (set manually in the page-record) and "tstamp" will use the "tstamp"-field of the pagerecord, which is set automatically when the record is changed. "crdate" will use "crdate"-field of the pagerecord. starttime will use the starttime field. .entryLevel = where in the rootline the search begins. Standard rootline syntax (-x to x) .depth, .limit, .excludeNoSearchPages, .beginAtLevel (like "updated" menu) .setKeywords (+stdWrap) = lets you define the keywords manually by defining them as a commaseparated list. If this property is defined, it overrides the default, which is the keywords of the current page. .keywordsField = defines the field in the pages-table in which to search for the keywords. Default is the fieldname keyword. No check is done to see if the field you enter here exists, so enter an existing field, OK?! .keywordsField.sourceField = defines the field from the current page from which to take the keywords being matched. The default is keyword. (Notice that .keywordsField is only setting the page-record field to search in !) Support for Mount Pages: Yes. | |
| language | Creates a language selector menu. Typically this is made as a menu with flags for each language a page is translated to and when the user clicks any element the same page id is hit but with a change to the &L parameter in the URL.
The language type will create menu items based on the current page record but with the language record for each language overlaid if available. The items all link to the current page id and only &L is changed. Item states: When TSFE->sys_language_uid matches the sys_language uid for an element the state is set to ACT, otherwise NO. However, if a page is not available due to the pages Localization settings (which can disable translations) or if no Alternative Page Language record was found (can be disabled with .normalWhenNoLanguage, see below) the state is set to USERDEF1 for non-active items and USERDEF2 for active items. So in total there are four states to create designs for. It is recommended to disable the link on menu items rendered with USERDEF1 and USERDEF2 in this case since they are disabled exactly because a page in that language does not exist and might even issue an error if tried accessed (depending on site configuration). .value = comma list of sys_language uids to construct the menu with. The number of elements in this list determines the number of menu items. .normalWhenNoLanguage = boolean, which if set will render the button for a language as a non-disabled button even if no translation is found for the language. Example: Creates a language menu with flags (notice that some lines break): lib.langMenu = HMENU
lib.langMenu.special = language
lib.langMenu.special.value = 0,1,2
lib.langMenu.1 = GMENU
lib.langMenu.1.NO {
XY = [5.w]+4, [5.h]+4
backColor = white
5 = IMAGE
5.file = media/flags/flag_uk.gif || media/flags/flag_fr.gif || media/flags/flag_es.gif
5.offset = 2,2
}
lib.langMenu.1.ACT < lib.langMenu.1.NO lib.langMenu.1.ACT=1 lib.langMenu.1.ACT.backColor = black lib.langMenu.1.USERDEF1 < lib.langMenu.1.NO lib.langMenu.1.USERDEF1=1 lib.langMenu.1.USERDEF1.5.file = media/flags/flag_uk_d.gif || media/flags/flag_fr_d.gif || media/flags/flag_es_d.gif lib.langMenu.1.USERDEF1.noLink = 1 | |
| userdefined | Lets you write your own little PHP-script that generates the array of menuitems.
.file [resource] = filename of the php-file to include. (Just like cObject PHP_SCRIPT) .[any other key] = your own variables to your script. They are all accessible in the array $conf in your script Howto: You must populate an array called $menuItemsArray with page-records of the menuitems you want to be in the menu. It goes like this: $menuItemsArray[] = pageRow1; $menuItemsArray[] = pageRow2; $menuItemsArray[] = pageRow3; ... A pageRow is a record from the table pages with all fields selected (SELECT * FROM...) If you create fake page rows, make sure to add at least title and uid field values. Notice: If you work with mount-points you can set the MP param which should be set for the page by setting the internal field _MP_PARAM in the page-record (xxx-xxx). Overriding URLs: You can also use the internal field "_OVERRIDE_HREF" to set a custom href-value (eg. "http://www.typo3.org") which will in any case be used rather than a link to the page that the page otherwise might represent. If you use "_OVERRIDE_HREF" then "_OVERRIDE_TARGET" can be used to override the target value as well (See example below). Other reserved keys: _ADD_GETVARS can be used to add get parameters to the URL, eg. &L=xxx. _SAFE can be used to protect the element to make sure it is not filtered out for any reason. Creating submenus: You can create submenus for the next level easily by just adding an array of menu items in the internal field "_SUB_MENU" (See example below). Presetting element state If you would like to preset an element to be recognized as a SPC, IFSUB, ACT, CUR or USR mode item, you can do so by specifying one of these values in the key ITEM_STATE of the page record. This setting will override the natural state-evaluation. | |
| userfunction |
Calls a user function/method in class which should (as with userdefined above) return an array with page records for the menu. .userFunc = function-name |
[tsref:(cObject).HMENU.special]
Example: Creating hierarchical menus of custom links
By default the HMENU object is designed to create menus from pages in TYPO3. Such pages are represented by their page-record contents. Usually the "title" field is used for the title and the "uid" field is used to create a link to that page in the menu.
However the HMENU and sub-menu objects are so powerful that it would be very useful to use these objects for creating menus of links which does not relate to pages in TYPO3 by their ids. This could be a menu reflecting a menu structure of a plugin where each link might link to the same page id in TYPO3 but where the difference would be in some parameter value.
This can be easily done with the special-type "userdefined" (see table above) where you can return an array of menu items customly build in a PHP-script you write.
First, this listing creates a menu in three levels where the first two are graphical items:
script_ended = 0;
function jumpToUrl(URL) {
document.location = URL;
}
0: # ************************
1: # MENU LEFT
2: # ************************
3: lib.leftmenu.20 = HMENU
4: lib.leftmenu.20.special = userfunction
5: lib.leftmenu.20.special.userFunc = user_3dsplm_pi2->makeMenuArray
6: lib.leftmenu.20.1 = GMENU
7: lib.leftmenu.20.1.NO {
8: wrap = <tr><td>|</td></tr><tr><td class="bckgdgrey1" height="1"></td></tr>
9: XY = 163,19
10: backColor = white
11: 10 = TEXT
12: 10.text.field = title
13: 10.text.case = upper
14: 10.fontColor = red
15: 10.fontFile = fileadmin/fonts/ARIALNB.TTF
16: 10.niceText = 1
17: 10.offset = 14,12
18: 10.fontSize = 10
19: }
20: lib.leftmenu.20.2 = GMENU
21: lib.leftmenu.20.2.wrap = | <tr><td class="bckgdwhite" height="4"></td></tr><tr><td class="bckgdgrey1" height="1"></td></tr>
22: lib.leftmenu.20.2.NO {
23: wrap = <tr><td class="bckgdwhite" height="4"></td></tr><tr><td>|</td></tr>
24: XY = 163,16
25: backColor = white
26: 10 = TEXT
27: 10.text.field = title
28: 10.text.case = upper
29: 10.fontColor = #666666
30: 10.fontFile = fileadmin/fonts/ARIALNB.TTF
31: 10.niceText = 1
32: 10.offset = 14,12
33: 10.fontSize = 11
34: }
35: lib.leftmenu.20.2.RO < lib.leftmenu.20.2.NO
36: lib.leftmenu.20.2.RO = 1
37: lib.leftmenu.20.2.RO.backColor = #eeeeee
38: lib.leftmenu.20.2.ACT < lib.leftmenu.20.2.NO
39: lib.leftmenu.20.2.ACT = 1
40: lib.leftmenu.20.2.ACT.10.fontColor = red
41: lib.leftmenu.20.3 = TMENU
42: lib.leftmenu.20.3.NO {
43: allWrap = <tr><td>|</td></tr>
44: linkWrap (
45: | <img src="clear.gif" width="15" height="1" /> | 48:<img src="fileadmin/arrow_gray.gif" height="9" width="9" hspace="3" /> | 49:| | 50:
52: ) 53: }
The menu looks like this on a webpage:
The TypoScript code above generates this menu, but the items does not link straight to pages as usual. This is because the whole menu is generated from this array, which was returned from the function "menuMenuArray" called in TypoScript line 4+5
1: function makeMenuArray($content,$conf) {
2: return array(
3: array(
4: 'title' => 'Contact',
5: '_OVERRIDE_HREF' => 'index.php?id=10',
6: '_SUB_MENU' => array(
7: array(
8: 'title' => 'Offices',
9: '_OVERRIDE_HREF' => 'index.php?id=11',
10: '_OVERRIDE_TARGET' => '_top',
11: 'ITEM_STATE' => 'ACT',
12: '_SUB_MENU' => array(
13: array(
14: 'title' => 'Copenhagen Office',
15: '_OVERRIDE_HREF' => 'index.php?id=11&officeId=cph',
16: ),
17: array(
18: 'title' => 'Paris Office',
19: '_OVERRIDE_HREF' => 'index.php?id=11&officeId=paris',
20: ),
21: array(
22: 'title' => 'New York Office',
23: '_OVERRIDE_HREF' => 'http://www.newyork-office.com',
24: '_OVERRIDE_TARGET' => '_blank',
25: )
26: )
27: ),
28: array(
29: 'title' => 'Form',
30: '_OVERRIDE_HREF' => 'index.php?id=10&cmd=showform',
31: ),
32: array(
33: 'title' => 'Thank you',
34: '_OVERRIDE_HREF' => 'index.php?id=10&cmd=thankyou',
35: ),
36: ),
37: ),
38: array(
39: 'title' => 'Products',
40: '_OVERRIDE_HREF' => 'index.php?id=14',
41: )
42: );
43: }
Notice how the array contains "fake" page-records which has no uid field, only a "title" and "_OVERRIDE_HREF" as required and some other fields as it fits.
1. The first level with items "Contact" and "Products" contains "title" and "_OVERRIDE_HREF" fields, but "Contact" extends this by a "_SUB_MENU" array which contains a similar array of items. 2. The first item on the second level, "Offices", contains a field called "_OVERRIDE_TARGET". Further the item has its state set to "ACT" which means it will render as an "active" item (you will have to calculate such stuff manually when you are not rendering a menu of real pages!). Finally there is even another sub-level of menu items.
[edit] Anwendungsbeispiele
#Autor: Jonathan Uhlmann
#Ziel: Die erste Unterseite der aktuellen Seite soll ausgegeben werden
#Hinweis: wenn beim Menu special = directory die Eigenschaft special.value nicht definiert ist, dann wird die aktuelle Seitenid (PID) verwendet.
#
lib.unterseite = HMENU
lib.unterseite {
special = directory
includeNotInMenu = 1
maxitems = 1
1 = TMENU
1.noBlur = 1
1.NO = 1
wrap = <p> | </p>
}
