Legacy AutoNav Placeholder

Permalink
Hi There

I am retheming a site built in 5.6. I have updated to the last version of 5.6 but have no need to update (just explaining why the site isn't in 5.7)

I am retheming and need to get the Autonav header menu so I can have select parent menu items as 'placeholders', i.e. disabling their link. I do not want to 'replace_link_with_first_in_nav', which I know how to do.

This is something documented here:http://legacy-documentation.concrete5.org/tutorials/create-menu-pla...

however the autonav script was updated and so this method does not work in 5.6.3.4.

Is their an easy way to achieve this using a custom attribute (say 'Disable Link In Nav') in the same manner? Sorry I do not understand the php for the autonav.

I do get C5 and have used lots, and also have google / searched, but all references either lead to the old code or replace link with first in nav.

Thanks in advance for your help/

 
hutman replied on at Permalink Best Answer Reply
hutman
You should be able to do this

foreach ($navItems as $ni) {
    $pageLink = $ni->url;
   if($ni->cObj->getAttribute('placeholder')) {
      $pageLink = 'javascript:void(0)';
   }
   echo '<li class="' . $ni->classes . '">'; //opens a nav item
   echo '<a href="' . $pageLink . '" 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)
   }
}
tobyme replied on at Permalink Reply
WORKS PERFECTLY.

Thanks for such a quick reply. Hugely appreciated.