2

My idea was to get the example nav bar from bootstrap website and then exchange the content of the navbar with the joomla code to get the menu.

The final product is:

<!-- Begin Navbar-->
<nav class="navbar navbar-default">
    <div class="container-fluid">
         <!-- Brand and toggle get grouped for better mobile display -->
         <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
         </div>
         <!-- Collect the nav links, forms, and other content for toggling -->
         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
             <jdoc:include type="modules" name="menu"/>
         </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
</nav><!--End navbar-->

This does not work because the format is gone now, so I tried adding "nav navbar-nav navbar" to "Module Class Suffix".

What is wrong with my intuition of how it works? Doesn't <jdoc:include type="modules" name="menu"/> just print out the <ul><li> which will be formatted by using nav navbar and navbar-nav?

1

Your menu will work as long as your template implement the Bootstrap nav component.

There are several extensions in JED that already generate the proper structure to show a Bootstrap nav menu. You can implement any of them to check the best practices and build your extension on top.

0

You can create a template override for the mod_menu. In there simply write your own code for the output of the mod_menu.

To create a template override for the menu module:

  • Locate (or create if not exists) the following path folders: templates/yourTemplate/html/mod_menu

  • Copy the default.php from modules/mod_menu/tmpl/, to the above location.

  • In this override file you can write your desired code for the layout output of the menu module.

I am sure this page will be very useful:
Joomla: Understanding Output Overrides

Note that usually most templates come with their own template override for the mod_menu. If you don't want to change the layout that comes with your template, then you could go with an Alternative Layout.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.