Forum
Blog section menu within main site navigation
I've created a conditional menu that displays a dropdown menu if a page has subpages. My client wants mutiple sections within their blog, so I want to create a dropdown from the Blog link in the sites main menu.
I'm not sure how to do this though! This is the code for my current navigation template –
<perch:before>
<perch:if id="pageDepth" value="1" match="eq">
<ul class="main clearfix">
<perch:else />
<ul class="dropdown-menu">
</perch:if>
</perch:before>
<li<perch:if exists="current_page"> class="active"</perch:if>>
<perch:if exists="subitems">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><perch:pages id="pageNavText" /> <b class="caret"></b></a>
<perch:pages id="subitems" encode="false" />
</li>
<perch:else />
<a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
</perch:if>
</li>
<perch:after>
</ul>
</perch:after>
Hoping somebody can help. Thank you!
What would the drop down have? Section titles?
Yup, that's correct – section titles linked to the individual blog sections.
You can use
perch_blog_sections()
to get the list of sections and pass it into the template:and then output it in the template:
Thanks Drew. It's so nearly there, but I need to wrap the blog sections with <ul class="dropdown-menu">.
I've tried a number of things but it's only outputting <ul>. Is there a template file I can set for this dropdown?
What template is your
perch_blog_sections()
call using?Drew, thanks for pointing this out.
I created a link only template and set the template in the perch_blog_sections() array within runtime.php – now the menu is giving me the desired effect.