Autonav template with image creates strange HTML

Permalink
Hi, I am using the default template for custom classes and added a custom attribute for a image per menu item in it but it generates strange HTML output. What am I doing wrong?

echo '<ul class="nav">'; //opens the top-level menu
foreach ($navItems as $ni) {
   $image = $ni->cObj->getAttribute('nav_item_image');
       if ($image){$image_url = $image->getURL();}
       else {$image_url = 'noimage.jpg';}
   }
   echo '<li class="' . $ni->classes . '"><img src="' . $image_url . '" class="nav_icon" />'; //opens a nav item
   if ($ni->isEnabled) {
      echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '<i class="fa ' . $ni->attrClass . '"></i></a>';
   } else {
      echo '<span class="' . $ni->classes . '">' . $ni->name . '</span>';
   }
   if ($ni->hasSubmenu) {
      echo '<ul>'; //opens a dropdown sub-menu
   } else {

2 Attachments

 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
I would expect an autonav block that fetches images from a page attribute would be very resource heavy.
I find a css method using an image sprite to be much lighter on resources.
An example of which can be seen on this 5.6 site...
http://www.deepsea.co.uk/
tallacman replied on at Permalink Reply
tallacman
One of the manual nav blocks has this option if you want a prepackaged solution.