Font awesome in Auto Nav
Permalink
Hello guys,
I am trying to add Font Awesome icons to an Auto Nav template. My php skills are still very nubile so I'm in need of some help.
I've added a custom page attribute in the form of an HTML tag that has to be added to each page. I've also added it to the view.php file of my template. My problem is echoing the php class to a list class.
On line 7 I've echoed the class but that isn't the solution as it adds the same attribute to all list items. But each list item should have the "favi" attribute as class.
I am trying to add Font Awesome icons to an Auto Nav template. My php skills are still very nubile so I'm in need of some help.
I've added a custom page attribute in the form of an HTML tag that has to be added to each page. I've also added it to the view.php file of my template. My problem is echoing the php class to a list class.
$favicon = $c->getAttribute('favi');
if (count($navItems) > 0) { echo '<ul class="menu">'; //opens the top-level menu foreach ($navItems as $ni) { echo '<li class="paddingRight" ' . $ni->classes . '">' ; //opens a nav item echo $favicon;//<---- FONT AWESOME ICON echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>'; if ($ni->hasSubmenu) { echo '<ul>'; //opens a dropdown sub-menu } else { echo '</li>'; //closes a nav item echo str_repeat('</ul></li>', $ni->subDepth); //closes dropdown sub-menu(s) and their top-level nav item(s) } } echo '</ul>'; //closes the top-level menu } elseif (is_object($c) && $c->isEditMode()) {
Viewing 15 lines of 18 lines. View entire code block.
On line 7 I've echoed the class but that isn't the solution as it adds the same attribute to all list items. But each list item should have the "favi" attribute as class.
Try putting your code up above in the Step 1 of 2 foreach loop like this
I had to change the attributes values to just the class names and it worked as a charm. Thanks a lot!
Could this work for the whale manual nav plugin. I wanted a little more flexibility then the Auto Nav menu has?
@stewblack23
The Nestable Manual Nav view.php is very similar to the core Auto-Nav view.php. You should be able to use similar techniques with both since they are working with page objects.
https://github.com/shahroq/whale_manual_nav/blob/master/blocks/whale...
The Nestable Manual Nav view.php is very similar to the core Auto-Nav view.php. You should be able to use similar techniques with both since they are working with page objects.
https://github.com/shahroq/whale_manual_nav/blob/master/blocks/whale...