Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 841
Dr3w Br1ck13 Avatar asked Oct 27 '25 18:10

Dr3w Br1ck13


1 Answers

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 %}
like image 67
markwalker_ Avatar answered Oct 29 '25 07:10

markwalker_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!