Skip to main content
removed "Drupal" from the title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How can I add my bootstrapBootstrap classes to Drupala custom menu?

How can I add different bootstrapBootstrap menus to menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working on to get all menus and sub-menus.

<?php 
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

<div class="navbar-collapse collapse">
  <div class="menu-top-menu-container">
    <ul id="menu-top-menu" class="nav navbar-nav">
      <li>
        <a href="http://example.com/">Home</a>
      </li>
      <li>
        <a href="http://example.com/biography/">Biography</a>
      </li>
      <li>
        <a href="#">Services</a>
        <ul class="sub-menu"> <!-- Like this. -->
          <li></li>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</div>

Thanks, any help will be greatly appreciated!!

How can I add my bootstrap classes to Drupal custom menu

How can I add different bootstrap menus to menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working on to get all menus and sub-menus.

<?php 
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

<div class="navbar-collapse collapse">
  <div class="menu-top-menu-container">
    <ul id="menu-top-menu" class="nav navbar-nav">
      <li>
        <a href="http://example.com/">Home</a>
      </li>
      <li>
        <a href="http://example.com/biography/">Biography</a>
      </li>
      <li>
        <a href="#">Services</a>
        <ul class="sub-menu"> <!-- Like this. -->
          <li></li>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</div>

Thanks, any help will be greatly appreciated!!

How can I add my Bootstrap classes to a custom menu?

How can I add different Bootstrap menus to menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working on to get all menus and sub-menus.

<?php 
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

<div class="navbar-collapse collapse">
  <div class="menu-top-menu-container">
    <ul id="menu-top-menu" class="nav navbar-nav">
      <li>
        <a href="http://example.com/">Home</a>
      </li>
      <li>
        <a href="http://example.com/biography/">Biography</a>
      </li>
      <li>
        <a href="#">Services</a>
        <ul class="sub-menu"> <!-- Like this. -->
          <li></li>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</div>

I How can I add my bootstrap classes to Drupal custom menu

How can I add different bootstrap menus to menu_tree_output!!menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working inon to get all menus and submenussub-menus.

<?php 
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

        <div class="navbar-collapse collapse">
          <div class="menu-top-menu-container">
       <ul id="menu-top-menu" class="nav navbar-nav">
        <li>
            <a href="http://dev1.auroin.com/frankpanarophotographyexample.com/cms/">Home</a><a>
      </li>
<li><a      <li>
        <a href="http://dev1.auroin.com/frankpanarophotographyexample.com/cms/biography/">Biography</a><a>
      </li>
<li >     <li>
        <a href="#">Services</a>
        <ul class="sub-menu"> <!-- Like this. -->
          <li></li>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</div> 

Thanks, any help will be greatly appriciatedappreciated!!

I can I add my bootstrap classes to Drupal custom menu

How can I add different bootstrap menus to menu_tree_output!!

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them working for me. However, I have tried a number snippets and here is the latest piece of code I am working in to get all menus and submenus.

<?php 
$menuTree = menu_tree_all_data('main-menu');
$menu_tree_array = menu_tree_output($menuTree);
print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

        <div class="navbar-collapse collapse">
          <div class="menu-top-menu-container">
       <ul id="menu-top-menu" class="nav navbar-nav">
        <li>
            <a href="http://dev1.auroin.com/frankpanarophotography.com/cms/">Home</a></li>
<li><a href="http://dev1.auroin.com/frankpanarophotography.com/cms/biography/">Biography</a></li>
<li >
    <a href="#">Services</a>
<ul class="sub-menu">
    <li></li>
    <li></li>
</ul>
</div>
</div> 

Thanks, any help will be greatly appriciated!!

How can I add my bootstrap classes to Drupal custom menu

How can I add different bootstrap menus to menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working on to get all menus and sub-menus.

<?php 
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

<div class="navbar-collapse collapse">
  <div class="menu-top-menu-container">
    <ul id="menu-top-menu" class="nav navbar-nav">
      <li>
        <a href="http://example.com/">Home</a>
      </li>
      <li>
        <a href="http://example.com/biography/">Biography</a>
      </li>
      <li>
        <a href="#">Services</a>
        <ul class="sub-menu"> <!-- Like this. -->
          <li></li>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</div>

Thanks, any help will be greatly appreciated!!

Source Link

I can I add my bootstrap classes to Drupal custom menu

How can I add different bootstrap menus to menu_tree_output!!

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them working for me. However, I have tried a number snippets and here is the latest piece of code I am working in to get all menus and submenus.

<?php 
$menuTree = menu_tree_all_data('main-menu');
$menu_tree_array = menu_tree_output($menuTree);
print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

        <div class="navbar-collapse collapse">
          <div class="menu-top-menu-container">
       <ul id="menu-top-menu" class="nav navbar-nav">
        <li>
            <a href="http://dev1.auroin.com/frankpanarophotography.com/cms/">Home</a></li>
<li><a href="http://dev1.auroin.com/frankpanarophotography.com/cms/biography/">Biography</a></li>
<li >
    <a href="#">Services</a>
<ul class="sub-menu">
    <li></li>
    <li></li>
</ul>
</div>
</div> 

Thanks, any help will be greatly appriciated!!