Untermenü erstellen
From Joomla! Documentation
So wird ein Untermenü in einer Joomla!-Website erstellt
Bei Joomla! können Untermenüs entweder mit zwei, mit mehreren Ebenen oder komplett separat in einem Menü-Modul angezeigt werden. Dies ist sehr nützlich bei Menüstrukturen, die die Navigation über mehreren Ebenen anzeigen sollen, sowie Untermenüeinträgen, die in ganz unterschiedlichen Positionen innerhalb des eigenen Templates dargestellt werden. Um dies umzusetzen, wird hier eine Schritt-für-Schritt Anleitung zur Erstellung von Menüeinträgen über mehrere Ebenen beschrieben und wie diese auf der Website in separaten Positionen angezeigt werden können.
Drei Navigationspunkte sind zur Erstellung eines Menüs nötig:
- Inhalt - hier wird der Inhalt erstellt. Er kann aus Beiträgen, Kategorien oder Links bestehen.
- Menüs - hier werden die Menüs erstellt. Es können neue Menüpunkte erstellt, Reihenfolgen geändert, sowie das Eltern-/ Kindverhalten bearbeitet werden.
- Module - Unter dem Menüpunkt "Erweiterungen / Module" kann eingestellt werden, ob und wo, ein Menü angezeigt wird.
Für diese Anleitung sind Administrationsrechte erforderlich. Wer nicht weiß, wie man sich als Administrator anmeldet, liest bitte diesen Artikel: Im Backend An- oder Abmelden.
Bemerkung: Für diese Anleitung wird eine der folgendenden Berechtigungen benötigt: - Berechtigung zum Erstellen oder Bearbeiten von Beiträgen, Menüs und Modulen - Rechte als "Superuser" Nähere Informationen über die Rechteverwaltung unter: Zugriffssteuerung
Schritt 1 - Erstellen eines Beitrags
In unserem Beispiel erstellen wir Menüpunkte für "Dogs" und "Cats". - Unter dem Menüpunkt "Dogs" fügen wir die Unterpunkte "Collies" und "Pomeranians ein. - Unter dem Menüpunkt "Cats" fügen wir die Unterpunkte "Burmese" und "Russian Blues" ein. Damit sieht unsere Menüstruktur folgendermaßen aus:
- Dogs
- Collies
- Pomeranians
- Cats
- Burmese
- Russian Blues
Zuerst erstellen wir die vier Beiträge, auf die wir verlinken möchten. Also die Beiträge für: "Collies", "Pomeranians", "Burmese" und "Russian Blue". Wenn Sie nicht wissen, wie Sie einen Beitrag erstellen können, lesen Sie bitte diesen Artikel: Adding a new Article/de.
Schritt 2 - Erstellen eines Hauptmenüpunktes
Um die Menüstruktur erstellen zu können, navigieren wir zu dem Menü, in dem wir die Untermenüs erstellen möchten (z.B.: Hauptmenü). Handelt es sich dabei um ein neues Menü, müssen wir dieses zuerst anlegen. Wenn Sie nicht wissen, wie Sie Menüpunkte erstellen können, lesen Sie bitte diesen Artikel: Adding a new menu/de.
Im entsprechenden Menü wählen wir '"neuer Menüeintrag"'. Um einen Hauptmenüpunkt zu erstellen wählen wir unter '"Menüeintragstyp"' den Punkt '"Systemlinks"' → '"Menü-Überschrift"'. Diesen Vorgang führen wir für die beiden Punkte "Dogs" und "Cats" aus.
Es gibt auch noch weitere Menüeintragstypen, die als Hauptmenüpunkt geeignet sind.
Mit den folgenden Schritten legen wir unsere Unterpunkte an. Wenn Sie nicht wissen, wie Sie Menüpunkte anlegen können, lesen Sie bitte diesen Artikel: Wie füge ich ein neues Menü hinzu?
- Zu Menüs → Ihr Menü navigieren
- Auf Neu klicken
- For the purposes of this exercise we are creating "placeholder" links using the System → External URL menu type for the Dogs and Cats parent level menu items. So, in the new Menu Item, click on the Menu Type select button:
- Click on System Links then scroll down and select External URL.
- Add the Menu Item Title ("Dogs") and type in a hashtag "#" in the Link box.
- Save your menu item.
- Repeat steps 2 - 6 for the Cats Parent Level menu item.
Step 3 - Create the Sublevel Menu Items
Now you will add the sublevel menu items using the Articles → Single Article to create menu links to the individual pages Collies, Pomeranians, Burmese, and Russian Blues. For each Menu Item created, we will set the Parentage to Dogs or Cats.
For more detailed information on how to create a Single Article Menu Type, see: Adding a menu item which points to an Article.
Note: There are other menu item types that can be used for the sublevel navigation structure.
- In the toolbar, click on "New".
- In the new Menu Item click on the Menu Type select button:
- Select Articles → Single Article from the list displayed.
- Returning to the Menu Item Detail page, click on the Select Article List.
- Select the Collies article for this example.
- On returning to the Article Detail page, fill in the Menu Item Title. Then click on the Parent Item select list located in the far right column. Find and select the Dogs parent item by scrolling through the Parent Item List. Note that menu levels are displayed with dashes: "-" (single dash) is the highest level, "--" (two dashes) is the second level, "---" third level and so on.
- Click on the button Save & Close up in the top button.
- Repeat steps 1-7 for the remaining articles Pomeranians with the Dog parent and articles Burmese and Russian Blues for the Cat parent.
- When you are finished with the "Menu Items" section, the Menu Item Manager should look very similar to the following:
Step 4 - Setup the Menu Module
At this point, we have our Articles and Menu Items done. Now we need to update the Menu Module. In Joomla!, the Menu Module determines three main things:
- What the menu looks like;
- Where on the page it will show;
- Which pages it will show on.
We will do two examples:
- In the first example, we will set the parameters that show the parent level menu items with the lower level items beneath.
- In the second example, we will add an additional menu module that appears in the left column and shows only the second level menu items.
Note: We will do both examples using the Protostar Template included in the core Joomla! installation.
Example 1 - One Menu Module With Second Level Menu Items
To show this as one module, follow these steps:
- Navigate to Extensions → Module Manager and locate the Menu Module associated with your menu. If you need to create a new menu module, for instructions on creating a menu module, see: Module Menu
- Click on the module name associated with your menu. In this tutorial, we are selecting Main Menu. Note: this image has been filtered by selecting Menu in the Module type dropdown.
- In the Module details, set the Start level to 1, the End Level to All and set Show Submenu Items to Yes.
- For this tutorial, we have added some styling in the Advanced tab. In the Menu Class Suffix we have entered navbar-nav nav-pills. You can also add navbar-nav nav-tabs for a slightly different look. Note: there is a space before navbar-nav.
- Click on Save & Close.
- Go to the frontend of your site and your menu should look similar to this. In the Protostar Template, the sublevel menu items are displayed as dropdown menu items.
- The source code generated will look similar to this:
<ul class="nav menu navbar-nav nav-pills">
<li class="item-101 current active"><a href="/" >Home</a></li>
<li class="item-102"><a class="dropdown-toggle" href="/about-us" >About Us</a></li>
<li class="item-210 deeper parent"><a href="#" >Dogs</a>
<ul class="nav-child unstyled small">
<li class="item-212"><a href="/2015-11-24-14-19-31/collies" >Collies</a></li>
<li class="item-213"><a href="/2015-11-24-14-19-31/pomeranians" >Pomeranians</a></li>
</ul>
</li>
<li class="item-211 deeper parent"><a href="#" >Cats</a>
<ul class="nav-child unstyled small">
<li class="item-214"><a href="/2015-11-24-14-20-12/burmese" >Burmese </a></li>
<li class="item-215"><a href="/2015-11-24-14-20-12/russian-blues" >Russian Blues</a></li>
</ul>
</li>
</ul>
Example 2 - A Second Menu Module With Child Level Menu Items
To show in a separate module in a different position, follow these steps:
- Navigate to Extensions → Module Manager and locate or create a second Menu Module associated with your menu. If you are unfamiliar with how to create a new menu module, for instructions on creating a menu module, see: Module Menu
- Click on the module name associated with your menu. In this tutorial, we are selecting Left Menu. Note: this image has been filtered by selecting Menu in the Module type dropdown.
- In the Module details, set the Start level to 2, the End Level to All and set Show Submenu Items to Yes. Note the position has changed and the menu we are pointing to is the Main Menu.
- For this tutorial, we have used the Menu Assignment tab and assigned this Menu Module to appear on all pages except the home page.
- Click on Save & Close.
- Go to the frontend of your site and navigate to the Collies article. Your menu should look similar to this. Notice the child level subitems are the only items showing.
- The source code generated will look similar to this:
<ul class="nav menu">
<li class="item-212 current active"><a href="/2015-11-24-14-19-31/collies" >Collies</a></li>
<li class="item-213"><a href="/2015-11-24-14-19-31/pomeranians" >Pomeranians</a></li>
</ul>
Sub-Sub-Menus
Using this same technique, it is easy to create third-level sub-menus. You just make the Parent Menu Item a second-level sub-menu. Then you could use the same technique to create a separate Menu Module with Start Level of 2 and End Level of 3. This would show only the third-level Menu Items.