How I made an expanding menu with jQuery and autoNav

Permalink
Someone else might find this useful. I am converting an existing joomla site over to Concrete, and the prev version I made had a jQuery.treeview based menu system. The problem that I ran into was that all of the items in the menu tree had to be pages or external links in order to be in the list. So I couldn't have a placeholder list element to allow me to expand one section of the menu.

I made a slight change to the view.php of the AutoNav block:

if ($c->getCollectionID() == $_c->getCollectionID()) { 
echo('<li class="nav-selected"><a class="nav-selected" href="' . $pageLink . '">' . $ni->getName() . '</a>');
} else {
echo('<li><a href="' . $pageLink . '">' . $ni->getName() . '</a>');
}


became:

if ($c->getCollectionID() == $_c->getCollectionID()) { 
echo('<li class="nav-selected"><a class="nav-selected" href="' . $pageLink . '">' . $ni->getName() . '</a>');
} else {
if ($pageLink !== "placeholder" ){
echo('<li><a href="' . $pageLink . '">' . $ni->getName() . '</a>');
} else {
echo('<li><span>' . $ni->getName() . '</span>');
}
}


Now if the item is an external link, it checks to see if the link is to a page called 'placeholder' - if it is, then it replaces the link with just a span instead of an actual link.

In the site map, I created an external link for each of my expandable categories, and put 'placeholder' in for the link text (no http or anything.) Then I moved the pages I wanted as sub pages under this link.

When you move them under the link, they lose all the permissions for editing and viewing, even for administrators. You have to explicitly set the permissions, after that, they work fine.

Hopefully this helps someone else out, it should work for most menus that need to have a category placeholder for sub menu items. It is a little frustrating that you have to set every single sub page's permissions, but I don't really see a way around that. It looks like the permissions are inherited from the parent page in Concrete, and the external links do not have a permission set to inherit from...

hereNT
View Replies:
synlag replied on at Permalink Reply
synlag
Thx.