Forum
Bootstrap Navigation with Dropdown
Hello,
I am trying to have subpages show as dropdowns in my primary navigation. I have searched the forum and found some other threads regarding the topic, but I wasn't able to gather how to implement the suggestions.
Here's what my nav template (prior to adding to Perch) looks like:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Menu</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Programs</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">News</a></li>
<li><a href="#">FAQs</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">FAQ 1</a></li>
<li><a href="#">FAQ 2</a></li>
<li><a href="#">FAQ 3</a></li>
<li role="separator" class="divider"></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container-fluid -->
</nav>
How would I go about implementing this into my site? Right now this is all I have:
index.php navigation area:
<div id="navbar" class="navbar-collapse collapse">
<?php perch_pages_navigation(); ?>
</div>
item.html:
<perch:before>
<ul class="nav navbar-nav">
</perch:before>
<li<perch:if exists="current_page"> class="selected"</perch:if><perch:if exists="ancestor_page"> class="ancestor"</perch:if>>
<a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
<perch:pages id="subitems" encode="false" />
</li>
<perch:after>
</ul>
</perch:after>
Thank you for your assistance!
Hi Trevor,
I was working through this a few months ago, this is my forum string with Drew, it might help:
https://forum.grabaperch.com/forum/08-04-2015-responsive-dropdown-navigation
Thank you for the suggestion. I am still having issues, though.
Hi Trevor,
For Bootstrap nav I split the templates into two. I think this should work for you:
In your page the Perch Navigation function would be:
Then have this template in
perch/templates/navigation/level1.html
and this in
perch/templates/navigation/level2.html
Hi there,
Thank you for your reply, Simon. I tried what you suggested, but no drop down is showing when I hover the links:
https://pacasatesting.site/about-pa-casa/
The links listed under "Additional Information" should show under "About" as they are subpages.
If you compare the HTML output you're getting with the HTML you actually want, how is it different?
What's being output:
I'm pretty sure I need this to output when there are subpages:
Ok, so are you testing for
subitems
?