J3.x

Creating a submenu

From Joomla! Documentation

Revision as of 20:43, 14 October 2019 by Ino (talk | contribs) (Created page with "*Menu - descrive le voci di menu, il tipo di navigazione, la loro relazione genitore/figlio con altre voci di menu e l'ordine di visualizzazione.")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
Deutsch • ‎English • ‎Nederlands • ‎eesti • ‎español • ‎français • ‎italiano
Tutorial
Come creare un sottomenu in un sito Joomla!
Joomla! 
3.x

In Joomla, i sottomenu possono essere visualizzati come un unico menu a due o più livelli o come moduli di menu completamente separati. Questo è utile per costruire menu che mostrano la navigazione a livello genitore e figlio o per mostrare le voci di menu di sottolivello in posizioni completamente separate sul modello. Per mostrare come fare questo, passeremo attraverso la creazione di voci di menu a livello genitore e figlio e poi vedremo come mostrare queste voci all'interno di un unico grande menu e come menu separato con solo le voci di livello figlio che mostrano in una posizione separata su un modello.

Per iniziare, i menu funzionano con tre costruzioni di base:

  • Articoli - hai bisogno di contenuti a cui collegarti. Questo può anche essere componenti, altre voci di menu o link esterni.
  • Menu - descrive le voci di menu, il tipo di navigazione, la loro relazione genitore/figlio con altre voci di menu e l'ordine di visualizzazione.
  • Menu Module - controls the position and displaying of the menu.

For this tutorial, begin by logging into the Joomla Administrator. If you are unfamiliar with how to login see this article: Logging in or out of the Administrator backend.

Note: For this tutorial you need Super Administrator permissions or permissions open enough to create and modify Articles, Menu Items, and Modules. For more information on User Access Control see: ACL Tutorial.

Step 1 - Create Your Articles

In our example, we will create top level menu items for Dogs and Cats. Under Dogs, we will have Collies and Pomeranians. Under Cats we will have Burmese and Russian Blues. So the structure of our sample menu items will be as follows:

  • Dogs
    • Collies
    • Pomeranians
  • Cats
    • Burmese
    • Russian Blues

First, create 4 articles so our menu items will have something to link to: Collies, Pomeranians, Burmese and Russian Blue. See this tutorial if you need help creating an Article: Adding a new Article.

Step 2 - Create the Parent Level Menu Items

To create the structure, we need to navigate to the menu where we want our new menu items. If this is a new menu, you will need to create it. See this tutorial on how to create a menu: Adding a new menu.

Once you have your menu located in the Menu Manager, you will add the parent menu items using the System Links  External URL for each navigation link: Dogs and Cats.

Please note, there are other menu item types that can be used for the parent level navigation structure.

Here are the steps to create sample Menu Items using our example data. For more information on creating Menu Items see: Adding a new menu item.

  1. Navigate to the Menu Manager by clicking on Menus  Menu Manager
    J3x-Edit-Main-Menu-en.jpg
  2. In the toolbar, click on New
    J3x-Edit-Main-Menu-Toolbar-new-en.png
  3. 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:
    J3x-Add-Main-Menu-Select-Type-en.png
  4. Click on System Links then scroll down and select External URL.
    J3x-Create-Sublevel-Menu-System-External-Url-en.png
  5. Add the Menu Item Title ("Dogs") and type in a hashtag "#" in the Link box.
    J3x-Create-Sublevel-Menu-Menu-Item-External-Url-en.png
  6. Save your menu item.
    Joomla-3-Menu-Add-Menu-Save-en.png
  7. 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.

  1. In the toolbar, click on "New".
    J3x-Edit-Main-Menu-Toolbar-new-en.png
  2. In the new Menu Item click on the Menu Type select button:
    J3x-Add-Main-Menu-Select-Type-en.png
  3. Select Articles  Single Article from the list displayed.
    J3x-Add-Main-Menu-Article-Type-en.png
  4. Returning to the Menu Item Detail page, click on the Select Article List.
    J3x-Add-Main-Menu-Article-Select-Article-en.png
  5. Selezionare l'articolo Collie per questo esempio.
    J3x-Create-Sublevel-Menu-Menu-Item-Single-Article-en.png
  6. 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.
    J3x-Create-Sublevel-Menu-Select-Parent-Item-en.png
  7. Click on the button Save & Close up in the top button.
    Joomla-3-Menu-Add-Menu-Save-en.png
  8. Repeat steps 1-7 for the remaining articles Pomeranians with the Dog parent and articles Burmese and Russian Blues for the Cat parent.
  9. When you are finished with the "Menu Items" section, the Menu Item Manager should look very similar to the following:
    J3x-Create-Sublevel-Menu-Items-en.png


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:

  1. What the menu looks like;
  2. Where on the page it will show;
  3. 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:

  1. 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
    J3x-Create-Sublevel-Menu-Module-Control-Panel-en.png
  2. 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.
    J3x-Create-Sublevel-Menu-Module-List-Menus-en.png
  3. In the Module details, set the Start level to 1, the End Level to All and set Show Submenu Items to Yes.
    J3x-Create-Sublevel-Menu-Module-Details-en.png
  4. 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.
    J3x-Create-Sublevel-Menu-Module-Advanced-Menu-Class-Suffix-en.png
  5. Click on Save & Close.
    J3x-Create-Sublevel-Menu-Module-Save-en.png
  6. 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.
    J3x-Create-Sublevel-Menu-Frontend-Sample-Dropdown-en.png
  7. 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:

  1. 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
    J3x-Create-Sublevel-Menu-Module-Control-Panel-en.png
  2. 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.
    J3x-Create-Sublevel-Menu-Module-List-Menus-2-en.png
  3. 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.
    J3x-Create-Sublevel-Menu-Module-Details-2-en.png
  4. For this tutorial, we have used the Menu Assignment tab and assigned this Menu Module to appear on all pages except the home page.
    J3x-Create-Sublevel-Menu-Module-Module-Assignment-Tab-en.png
  5. Click on Save & Close.
    J3x-Create-Sublevel-Menu-Module-Save-en.png
  6. 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.
    J3x-Create-Sublevel-Menu-Frontend-Sample-Child-Menu-en.png
  7. 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.