Menus werden in TYPO3 durch TypoScript definiert. Wie auch alle anderen TypoScript-Anweisungen werden die Menus damit zunächst durch die Datei /typo3/sysext/cms/tslib/class.tslib_content.php ausgwertet. Das eigentliche Frontend-Rendering der Menus findet standardmäßig durch die automatisch includierte Datei /typo3/sysext/cms/tslib/class.tslib_menu.php statt.
Auf Wunsch kann man zusätzlich oder statt dessen eigene Funktionen angeben, die das Rendering übernehmen bzw. ergänzen. In TypoScript können diesen Funktionen dann auch individuelle Parameter übergeben werden - eine entsprechende Auswertung muss in den Funktionen natürlich integriert werden.
In TypoScript gibt es die Möglichkeit verschiedenste Linkeigenschaften zu erkennen und gesondert zu behandeln. Die beiden einfachsten Zustände sind der Standardlink NO und die aktuelle Seite CUR. Durch diese Unterscheidung ist es bereits möglich dem Link auf die aktuelle Seite ein anderes Aussehen zu verleihen oder den Seitentitel ohne Verlinkung anzuzeigen.
Für die Handhabung in TypoScript ist die Art der Ausgabe weitgehend unwesentlich. Menus können als Tabellen, Listen, oder Divisions (DIVs) ausgegeben werden - hier ist die Phantasie des Programmierers der begrenzende Faktor. Die Einbindung notewendiger StyleSheets (CSS) im Header des Templates ist ebenfalls sehr vielseitig möglich, somit sind der Gestaltung keine Grenzen gesetzt.
Aufgrund der Vielfalt möglicher HTML-, CSS-, und TypoScript-Codes und bei speziellen Bedürfnissen kann es bei Menus zu komplizierten Konstrukten kommen - Dieses Kapitel soll verschiedene Lösungsvorschläge für spezielle Problemstellungen anbieten.
Rootline-Menus sind eine spezielle Form von Menus, wo vom Wurzelverzeichnis bis zur aktuellen Seite alle Seiten in hirarchischer Reihenfolge angeordnet werden. Ein einfaches Beispiel ist oben unter "Aktueller Seitenpfad:" zu sehen.
Nachfolgend wird ein Rootlinemenu aufgeführt, jedoch in einer etwas speziellen Form, nämlich daß die Seiten untereinander angezeigt und entsprechend ihrer Tiefe eingerückt werden. Außerdem ist die aktuelle Seite nicht verlinkt.
page.headerData.10 = TEXT
page.headerData.10.value (
<style type="text/css">
.special_rootline {font-size:small}
.special_rootline .s_rootline {background:url(typo3/gfx/arrowright.png) no-repeat;padding-left:16px;font-weight:bold}
.special_rootline .s_rootline_level_0 {margin-left:0px}
.special_rootline .s_rootline_level_1 {margin-left:8px}
.special_rootline .s_rootline_level_2 {margin-left:16px}
.special_rootline .s_rootline_level_3 {margin-left:24px}
.special_rootline .s_rootline_level_4 {margin-left:32px}
.special_rootline .s_rootline_level_5 {margin-left:40px}
.special_rootline .s_rootline_level_6 {margin-left:48px}
</style>
)
page.10 = HMENU
page.10 {
wrap = <div class="special_rootline">|</div>
special = rootline
1 = TMENU
1.NO.linkWrap = |*| <div class="s_rootline s_rootline_level_0">|</div> || <div class="s_rootline s_rootline_level_1">|</div> || <div class="s_rootline s_rootline_level_2">|</div> || <div class="s_rootline s_rootline_level_3">|</div> || <div class="s_rootline s_rootline_level_4">|</div> || <div class="s_rootline s_rootline_level_5">|</div> || <div class="s_rootline s_rootline_level_6">|</div> |*|
1.CUR < .1.NO
1.CUR = 1
1.CUR.doNotLinkIt = 1
}
The following Menu shows how option split is used with different itemStates.
Here option split is used to mark the items first, normal and last separated by |*|:
xyz.1.NO.wrapItemAndSub = <li class="first NO"> | </li> |*| <li class="normal NO"> | </li> |*| <li class="last NO"> | </li>
When you want to assign two classes per item you can use the following TS, in my example each item has one of the classes [first|normal|last] assigned, furthermore each item gets the current itemState as class too:
xyz = HMENU
xyz {
wrap = <ul id="yacbddm" class="firstLevel"> | </ul>
1 = TEMNU
1.noBlur = 1
1.NO.wrapItemAndSub = <li class="first NO"> | </li> |*| <li class="normal NO"> | </li> |*| <li class="last NO"> | </li>
1.IFSUB < .1.NO
1.IFSUB = 1
1.IFSUB.wrapItemAndSub = <li class="first IFSUB"> | </li> |*| <li class="normal IFSUB"> | </li> |*| <li class="last IFSUB"> | </li>
1.ACT < .1.NO
1.ACT = 1
1.ACT.wrapItemAndSub = <li class="first ACT"> | </li> |*| <li class="normal ACT"> | </li> |*| <li class="last ACT"> | </li>
1.CUR < .1.NO
1.CUR = 1
###### Optional: Don't link current item ######
1.CUR.doNotLinkIt = 1
1.CUR.wrapItemAndSub = <li class="first CUR"> | </li> |*| <li class="normal CUR"> | </li> |*| <li class="last CUR"> | </li>
2 < .1
2.wrap = <ul class="level_2">|</ul>
3 < .1
3.wrap = <ul class="level_3">|</ul>
4 < .1
4.wrap = <ul class="level_4">|</ul>
}
For the itemStates in the moment it doesn't make any sense to write 1.IFSUB < .1.NO but when .1.NO is more complicated all properties of .1.NO automatically are assigned to the other itemStates too.
For the classes of li-elements you can assign other classnames also only one name, but combining different names makes CSS easier because you can manage two different classes independent from hirarchy.
Below 2 < .1, 3 < .1, ... you can overwrite defined properties that are taken from .1, so you needn't define the whole TMENU new for each level.
The result only has the normal page-CSS assigned and looks like that:
The produced HTML-Source-Code of the Template looks like this:
<ul id="yacbddm" class="firstLevel">
<li class="first IFSUB"><a href=" ... " >Leistungen</a></li>
<li class="normal NO"><a href=" ... " >Referenzen</a></li>
<li class="normal ACT">
<a href=" ... " >Support</a>
<ul class="level_2">
<li class="first ACT">
<a href=" ... " >TYPO3</a>
<ul class="level_3">
<li class="first NO"><a href=" ... " >TYPO3 - Beschreibung</a></li>
<li class="normal ACT">
<a href=" ... " >Tipps und Tricks</a>
<ul class="level_4">
<li class="first NO"><a href=" ... " >Erweiterung: chc_forum</a></li>
<li class="normal NO"><a href=" ... " >Backend Fehlermeldungen</a></li>
<li class="normal NO"><a href=" ... " >Bugfixing mit "diff" und "patch"</a></li>
<li class="normal IFSUB"><a href=" ... " >Installation</a></li>
<li class="normal CUR">Navigation</li>
<li class="normal NO"><a href=" ... " >Mehrsprachigkeit</a></li>
<li class="normal NO"><a href=" ... " >class.tslib_pibase</a></li>
<li class="last NO"><a href=" ... " >UTF-8 in TYPO3</a></li>
</ul>
</li>
<li class="last IFSUB"><a href=" ... " >Snippets</a></li>
</ul>
</li>
<li class="normal IFSUB"><a href=" ... " >CSS</a></li>
<li class="normal NO"><a href=" ... " >HTML</a></li>
<li class="normal NO"><a href=" ... " >JavaScript</a></li>
<li class="normal NO"><a href=" ... " >Glossar</a></li>
<li class="normal IFSUB"><a href=" ... " >Windows</a></li>
<li class="normal NO"><a href=" ... " >Thunderbird</a></li>
<li class="normal NO"><a href=" ... " >Content Managementen Systeme</a></li>
<li class="normal NO"><a href=" ... " >Barrierefreiheit</a></li>
<li class="normal IFSUB"><a href=" ... " >Programmierung</a></li>
<li class="last IFSUB"><a href=" ... " >Forum</a></li>
</ul>
</li>
<li class="normal NO"><a href=" ... " >Kontakt</a></li>
<li class="last NO"><a href=" ... " >Impressum</a></li>
</ul>
Sometimes two independent menus have to be combined. You can create two pages (ABC, XYZ) inside pagetree somewhere you like and also you needn't care that both pages are on same level. Inside these containerpages add all your contentpages - optionally with subpages:
- Root
-- ABC
--- Page ABC 1
--- Page ABC 2
--- Page ABC 3
--- Page ABC 4
--- Page ABC 5
-- XYZ
--- Page XYZ 1
--- Page XYZ 2
--- Page XYZ 3
--- Page XYZ 4
lib.menu.combined = COA
lib.menu.combined {
### Outer Menu-Container:
wrap = <div class="combined_menu">|</div>
### first Menu:
10 = HMENU
10 {
special = directory
special.value = 1001
wrap= <ul class="Menu_ABC">|</ul>
1 = TMENU
1 {
noBlur = 1
expAll = 1
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li>
|*| <li class="last">|</li>
ACT < .NO
ACT = 1
ACT.ATagParams = class="active"
}
2 < .1
2.wrap = <ul>|</ul>
3 < .2
}
### Optionale divider-line, comment out to disable:
15 = TEXT
15.value = <hr />
### second Menu:
20 < .10
20.special.value = 869
20.wrap= <ul class="Menu_XYZ">|</ul>
}
page.100 < lib.menu.combined
The produced HTML looks like this:
<div class="combined_menu">
<li class="last"><a href=" ... " >Funktion strtotime multilingual
</a></li>
</ul>
</li>
<li class="last"><a href=" ... " >Links
</a></li>
</ul>
<li class="first"><a href=" ... " >TYPO3 - Beschreibung
</a></li>
<a href=" ... " class="active">Tipps und Tricks
</a>
<li class="first"><a href=" ... " >Erweiterung: chc_forum
</a></li>
<li><a href=" ... " >Backend Fehlermeldungen
</a></li>
<li><a href=" ... " >Bugfixing mit "diff" und "patch"
</a></li>
<a href=" ... " >Installation
</a>
<li class="last"><a href=" ... " >Image Processing
</a></li>
</ul>
</li>
<li><a href=" ... " class="active">Navigation
</a></li>
<li><a href=" ... " >Mehrsprachigkeit
</a></li>
<li><a href=" ... " >class.tslib_pibase
</a></li>
<li class="last"><a href=" ... " >UTF-8 in TYPO3
</a></li>
</ul>
</li>
<a href=" ... " >Snippets
</a>
<li class="last"><a href=" ... " >t3lib
</a></li>
</ul>
</li>
</ul>
</div>