Bootstrap nav-bar

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 3, 2014   (RSS)

By Toledoh - July 31, 2014

Hi Guys,

I'm trying to emulate the bootstrap navbar with the category menu generator.

The stock standard generator is

        <?php foreach ($pagesRecords as $categoryRecord): ?>
          <?php echo $categoryRecord['_listItemStart'] ?>
      
          <?php if ($categoryRecord['_isSelected']): ?>
            <b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
          <?php else: ?>
            <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
          <?php endif; ?>
      
          <?php echo $categoryRecord['_listItemEnd'] ?>
        <?php endforeach; ?>

I need to produce the following

        <li class="active"><a href="#">Category (no children / selected)</a></li>
        <li><a href="#">Category (no children)</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Category (with children) <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Child Category</a></li>
            <li><a href="#">Child Category</a></li>
            <li><a href="#">Child Category</a></li>
          </ul>
        </li>

Red: class=active for the selected category

Green: class-"dropdown" for when a category has children. 

Then,the link for that category is not the link_url, but <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>

the ul containing the children needs to have: class="dropdown-menu" role="menu"


Is that possible?

Cheers,

Tim (toledoh.com.au)

By Toledoh - August 3, 2014

Great - thanks Greg!

Cheers,

Tim (toledoh.com.au)