WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
  • Print
Pages: [1]   Go Down

Author Topic: Horizontal Menu utilizing Bootstrap 4.0.0-beta.2  (Read 11737 times)

Offline totage

  • Posts: 1
  • Gender: Male
  • WebGenie.ML Website Services
    • WebGenie.ML
Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
« on: December 10, 2017, 09:53:03 PM »
I'm modifying the default theme and converted the vertical nav menu into a horizontal menu. I'm still working on the project, but thought I'd share how I converted the menu in case anyone else would like to do so. Please feel free to post your input, improvements, etc.

First, you'll want to make sure you have Bootstrap loaded. Add the following in the header:

Code: [Select]
<!-- START BOOTSTRAP -->
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
 <!-- END BOOOTSTRAP -->

Once you've added Bootstrap, replace the NAV block with:

Code: [Select]
       <nav class="navbar navbar-default" role="navigation"><div class="container-fluid"><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>
       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
       <?php 
$open = '<li class="[if(class=menu-current||class=menu-parent){active}] [if(class==menu-expand){dropdown}]">
[if(class==menu-expand){<a href="[url]" class="dropdown-toggle" data-toggle="dropdown">[menu_title]<b class="caret"></b></a>}
else { <a href="[url]">[menu_title]</a> }]'
;
show_menu2(
$aMenu          = 1,
$aStart         = SM2_ROOT, 
$aMaxLevel      = SM2_CURR+1,
$aOptions       = SM2_ALL,
$aItemOpen      = $open,
$aItemClose     = '</li>',
$aMenuOpen      = ' <ul class="[if(level==0){nav navbar-nav} else {dropdown-menu}] ">',
$aMenuClose     = '</ul>',
$aTopItemOpen   = false,
$aTopMenuOpen   = false
);?>

    </ul></div></nav>

NOTES: This is very basic code to make a horizontal menu utilizing Bootstrap. This code may be incomplete and does have a few issues. One known issue is that when the page is displayed on mobile devices and/or in smaller windows, the menu does not work. You will see the hamburger menu, but nothing displays when you click on it. This issue will be fixed, and I'll update this post, unless someone else deceides to post the fix before me.

I'm modifying the default theme in WebsiteBaker 2.10 and will release it the near future for others to use and modify. More information on this project will be given at a later time, but keep an eye out for it, if interested!

You can see an example of this menu on my website, http://webgenie.ml.
Logged
WebGenie.ML Website Services

Offline nibz

  • Posts: 684
  • Gender: Male
Re: Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
« Reply #1 on: December 11, 2017, 01:16:45 PM »
Hello,

I think the problem is that jquery is loading twice.
Try this:
Go to Admin Tools > Frontend Output Filter > uncheck jQuery.
Logged

Offline nibz

  • Posts: 684
  • Gender: Male
Re: Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
« Reply #2 on: December 11, 2017, 08:42:55 PM »
Hello Totage,

I did a check. and its not only the jquery.
I also made a version which works for you will PM this to you.
Logged

Offline dehuisman

  • Posts: 24
  • Gender: Male
Re: Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
« Reply #3 on: April 12, 2018, 12:46:58 PM »
My version for bootstrap 4 is quite dirty because you are stuck with a trailing /div at the end in stead of a /ul. After outputbuffering I remove that change the trailing /div for /ul
any suggestions for a better solution?


Code: [Select]
$menu=show_menu2(1,SM2_ROOT,SM2_ALL,SM2_ALL|SM2_PRETTY|SM2_BUFFER,
'[if (level<1){<li class="nav-item}] [if (class==menu-expand && level<1){dropdown}] [if (level<1){">}]<a href="[url]" target="[target]" class="[if (class==menu-expand){dropdown-toggle }] [if (level<1){nav-link}else {dropdown-item}] [class] "  [if (class==menu-expand){ id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"}]>  [menu_title]   [if (class=menu-current){<span class="sr-only">(current)</span>}] </a>[if (level<1 && class!=menu-expand){</li>}] ',
'',
'<div class="dropdown-menu" aria-labelledby="navbarDropdown">',
'</div></li>',
false,
'<ul class="navbar-nav mr-auto">');

$menu = substr ($menu ,0,-13);
$menu.='</ul>';
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Horizontal Menu utilizing Bootstrap 4.0.0-beta.2
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2