Forum
Adding Icons to Navigation
I need to add a set of icons against my navigation bar, each item in the navigation having a different icon. I'm new to Perch and also PHP (background more in JS). Here is the site as it currently stands, with hard-coded icons and navigation bar. How would I go about doing this using the perch_pages_navigation function. Here is the code from the item.html file
`<perch:before>
<ul id="slide-out" class="side-nav fixed">
</perch:before>
<li id="<perch:content id='perch_item_index'/>"
<perch:if exists="current_page"> class="active"</perch:if> >
<a class="waves-effect" href="<perch:pages id="pagePath" />">
<perch:pages id="pageNavText"/>
</a>
<div class ="divider side-divider"></div>
<perch:pages id="subitems" encode="false"/>
</li>
<perch:after>
</ul>
</perch:after>`
Alex, I am not seeing the "hard coded" images in the code you post. Please post your entire template as well as example HTML your expecting from the template.
The best place to set the icon for the page would be as a page attribute. Those are available to the navigation functions.
Hi Robert, the code I am trying to achieve would be:
Where each of the menu items has a different
<i class="fa ... ></i>
Thanks Drew, but could you give me a bit more information about the page attributes please? I can't see anything about it on the Docs page. I had thought that in my template I would need to set up a bunch of
<perch:if>
statements to accomodate each of the different icons but if there was a way to do it through the attributes, that would be really handy.There is a video here https://docs.grabaperch.com/video/v/page-attributes/
and if you search the docs for "page attributes" you'll find all of the articles etc. that we have on the subject. https://docs.grabaperch.com/search/?q=page%20attributes
Thanks Rachel, my bad - It's been a long day and searching didn't cross my mind! I'll fix this tomorrow.