DjangoCMS - Adding multiple menus

30 Views Asked by At

I am trying to create a DjangoCMS webpage, but when I add the show menu to my page, the new pages added in CMS are duplicating on every instance of the show_menu tag, Is is possible to have multiple show_menu tag on the same html code that have the same capability for the CMS. I am able to add other show_menus but with static html code. my plan is to add multiple show_menus on the same page.

{% load static cms_tags menu_tags sekizai_tags %}
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8">
   </head>
<body>
    {% cms_toolbar %}
  <div class="sidebar close">
    <div class="logo-details">
      <i class='bx bxl-c-plus-plus'></i>
      <span class="logo_name"> LOGO </span>
    </div>
    {% block content1 %}{% endblock content1 %}
    <ul class="nav-links">
      <li>
        <a href="#">
          <i class='fa-solid fa-gauge' ></i>
          <span class="link_name">Dashboard</span>
        </a>
        <ul class="sub-menu blank">
          <li><a class="link_name" href="#">Dashboard</a></li>
        </ul>
      </li>
      <li>
        <div class="iocn-link">
          <a href="#">
            <i class='bx bx-book-alt' ></i>
            <span class="link_name">Applications</span>
          </a>
          <i class='fa-solid fa-chevron-down arrow' ></i>
        </div>
        <ul class="sub-menu">
          <li><a class="link_name" href="#">Applications</a></li>
        * >>>>>>>>>> {% show_menu 0 100 100 100 %}*
        </ul>
      </li>
      <li>
        <div class="iocn-link">
          <a href="#">
            <i class='bx bx-book-alt' ></i>
            <span class="link_name">Servers</span>
          </a>
          <i class='fa-solid fa-chevron-down arrow' ></i>
        </div>
        <ul class="sub-menu">
          <li><a class="link_name" href="#">Servers</a></li>
         * >>>>>>>>>> {% show_menu 1 100 100 100 %}*
        </ul>
      </li>
    </div>
  </li>
</ul>
  </div>
</body>
</html>
1

There are 1 best solutions below

0
markwalker_ On

Yeah you can have multiple show_menu tags, but if you feed them similar parameters you may get the same pages in each.

You are providing 4 parameters to the template tag, so these are;

  • start_level
  • end_level
  • extra_inactive
  • extra_active

How these behave depends entirely on how you structure your page tree. If you have a home page as a root node (i.e. level 0) and don’t want to display the root node(s), set start_level to 1.

It's this level 0 that you'll see first in your first menu. This menu keeps going through the tree to level 100.

Your second menu then starts at the next level, 1. And it also keeps going through the tree to level 100.

Depending on how deep your page tree goes, you could start with your two menus doing something like the following to so you get an understanding of this;

{% show_menu 0 2 %}

{% show_menu 2 6 %}

You might want to remove the third and fourth parameters until you start to see the results you want, but for clarity & taken from the docs;

The third parameter, extra_inactive (default=0), specifies how many levels of navigation should be displayed if a node is not a direct ancestor or descendant of the current active node.

The fourth parameter, extra_active (default=100), specifies how many levels of descendants of the currently active node should be displayed.