Forum
Navigation Template Issues
Hi have had a template that worked great when all my pages had sub pages under them.
I now need to have a home button on the menu and it will not work correctly. I am going spare trying to figure it out.
My code in the navigation template is this :
<perch:before>
<perch:if id="pageDepth" match="gt" value="1">
<ul class="dropdown-menu" role="menu">
<perch:else />
<ul class="nav navbar-nav">
</perch:if>
</perch:before>
<perch:if id="pageDepth" match="gt" value="1"><li><perch:else /><li class="dropdown"></perch:if><a href="
<perch:pages id="pagePath" />" <perch:if id="pageDepth" match="gt" value="1"> <perch:else />data-toggle="dropdown" class="dropdown-toggle" </perch:if> ><perch:pages id="pageNavText" /></a><perch:pages id="subitems" encode="false" /></li>
<perch:after>
</ul>
</perch:after>
and the output from this template is this:
<ul class="nav navbar-nav">
<li class="dropdown"><a href="/" data-toggle="dropdown" class="dropdown-toggle" >Home</a></li>
<li class="dropdown"><a href="/whats-on" data-toggle="dropdown" class="dropdown-toggle" >What's On</a>
<ul class="dropdown-menu" role="menu">
<li><a href="/alpha.php" >Alpha</a></li>
<li><a href="/calendar.php" >Calendar</a></li>
<li><a href="/children.php" >Children</a></li>
<li><a href="/services.php" >Services</a></li>
<li><a href="/small-groups.php" >Small Groups</a></li>
<li><a href="/students.php" >Students</a></li>
<li><a href="/youth.php" >Youth</a></li>
</ul>
</li>
<li class="dropdown"><a href="/how-can-we-help" data-toggle="dropdown" class="dropdown-toggle" >How Can We Help?</a>
<ul class="dropdown-menu" role="menu">
<li><a href="/city-centre-chaplain.php" >City Centre Chaplain</a></li>
<li><a href="/family-life-centre.php" >Counselling</a></li>
<li><a href="/marriage-courses.php" >Marriage Courses</a></li>
<li><a href="/pastoral-care.php" >Pastoral Care</a></li>
<li><a href="/prayer-support.php" >Prayer Support</a></li>
<li><a href="/social-and-ethical-issues.php" >Social and Ethical Issues</a></li>
</ul>
</li>
I think I just need to remove :
class="dropdown"><a href="/" data-toggle="dropdown" class="dropdown-toggle"
When it is only 1 single menu item with no sub pages.
Does any anyone have any ideas?
Thanks.
Phil
Just to clarify, everything in the above code works as it should.
I just need it tweaked so that the link to 'Home' does not have the class & data toggles.
It should look like:
How about just testing for it?
Thanks Drew. I have made some progress but can't get it just right.
With the following code I get the home page link working as it should ....
But the sub navigation inherits a lot of code - <li class="dropdown"><a href="/alpha.php" data-toggle="dropdown" class="dropdown-toggle">Alpha</a></li>
My output is now this:
What should it be like?
The output should look like :
You're adding those attributes yourself:
Yes. Those attributes need to be added to the parent pages. They should not be added to the submenu items.
Thats what I can't figure out.
I only want those attributes to be added to the parent pages, and only if they have submenu items, but not to the submenu items.
You can also test for
pageDepth
- it increases for each level you go down.But is the Home Link and the other Parent links not on the same depth?
If they are, I can't differentiate between them which I need to do.
The Home Page link is just a simple link, and the Parent pages are not, they just contain the submenu items.
Or could I put all pages as subpages of Home?
Is there something like:
If a page has child pages 'do this', otherwise ' do that' ?
Sure:
Drew you are a genius.
Thanks!
I on the other hand, really need to go and learn some PHP!