Forum
perch_pages_navigation in zurb foundation topbar
Newbie web developer here; I could really use some help. I'm trying to set up a global top bar navigation menu using zurb foundation classes
Just as an example:
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name"></li>
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li class="active"><a href="#">Home</a></li>
<li class="has-dropdown"><a href="#">Accommodations</a>
<ul class="dropdown">
<li><a href="#">King with Sofa Bed</a></li>
<li><a href="#">Two Queen Beds</a></li>
<li><a href="#">Pet-Friendly Suite</a></li>
</ul>
</li>
<li><a href="#">Reservations</a></li>
<li><a href="#">Meetings & Events</a></li>
<li><a href="#">Contact</a></li>
</ul>
</section>
</nav>
...is the 'static' html setup with foundation css / js that's works fine. I copied the above into perch/templates/layouts/global.topbar.php . I then deleted everything in the <ul class="right"> to </ul> portion and replaced it with <?php perch_pages_navigation(); ?> . I then tried tweaking the default /perch/templates/navigation/item.html file. However I have had little success in writing the Navigation template properly. I know that :
- The active page / <li> needs a class of "active"
- Any page / <li> with subpages needs a class of "has-dropdown"
- For any page <li> that is a subpage, the <ul> it is contained in needs a class of "dropdown"
I've read & re-read the perch_pages_navigation documentation, but I cannot figure out the detailed steps needed to get the template the way I would like it. Any help with this would be greatly appreciated.
What have you got so far, and where is it failing?
Well don't have much to show really.
I know above is completely wrong. Apart from everything else, one extremely basic thing I don't understand is how I can simply set just the very first <ul> to have class="right". On my test site, the above sets all my top-level pages' <li> entries (except, for some reason, the last one [which is just a link] ) to have a class="right".
Other than that I'm afraid I don't have too many specifics on what is failing . I simply currently at a loss of how to structure all this.
Test for
pageDepth
Alex, I don't know if you ever figured this out, but here is how I did exactly what you were trying to do. I used Drew's pageDepth to add the proper syntax for Foundation menus.
Here it is in readable code:
And here it is as I used it, to output clean looking line breaks in the source
I should mention my navigation was class "left", while your's was class "right".
Hope this helps someone!
Thank you so much for that James (@higgi3), that has just saved me a load of time :)