Dr3w Br1ck13
Dr3w Br1ck13

Reputation: 187

Django CMS: How to modify style of show_menu

I want to build a Django CMS template from a template found on https://startbootstrap.com.

I have load the following tags

{% load cms_tags menu_tags sekizai_tags staticfiles %}

and then within the <body> part the menu

...
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
  <div class="container">
    <a class="navbar-brand" href="#">Start Bootstrap</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
        {% show_menu 0 100 100 100 %}
      </ul>
    </div>
  </div>
</nav>
...

Unfortunately, the links for the pages in the menu have almost no CSS (see image).

menu without css

Basically, the links need to be of class nav-link. How can I fix this?

Upvotes: 4

Views: 3800

Answers (2)

Ma Jin
Ma Jin

Reputation: 41

<li class="nav-item">
    <a class="nav-link" href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
    {% if child.children %}
        <ul class="sub_menu">
            {% show_menu from_level to_level extra_inactive extra_active template '' '' child %}
        </ul>
    {% endif %}
</li>

Upvotes: 1

markwalker_
markwalker_

Reputation: 12859

You can use a custom template for the menu tags;

<ul class="dropdown">
    {% show_menu 1 100 100 100 "partials/navigation.html" %}
</ul>

Then in partials/navigation.html;

{% load cms_tags menu_tags cache cms_page %}

{% for child in children %}

    <li class="nav-link">
        <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
        {% if child.children %}
            <ul class="sub_menu">
                {% show_menu from_level to_level extra_inactive extra_active template '' '' child %}
            </ul>
        {% endif %}
    </li>

{% endfor %}

Upvotes: 7

Related Questions