Autonav - need a item that doesnt act as a page link

Hi there,

I’m wondering if it is possible with the autonav block to make pages that don’t work as a link nor show up in the sitemap or the URL. I want to make a menu with topics, once you click on a topic you go deeper in the menu with links that work. The sitemap/menu should look like this:

The (no link) items should just be placeholders for the navigation, without showing the page in the sitemap or URL to sub-pages.

  • Home
  • Topic 1 (no link)
    – Sub Item 1
    – Sub Item 2
    – Sub Item 3
  • Topic 2 (no link)
    – Sub Item1
    – Sub Item2
    – Sub Item3
  • Contact

I realize I can make a custom menu instead, but I still want to use the autonav to list the pages beneath a topic so I still need to make a parent page that does not get listed in the sitemap or URL.

This is what I want:

Please check out this addon:

Hi,

there is a built in attribute you can use for this.

Replace Link with First in Nav

Used by: Autonav
Handle: replace_link_with_first_in_nav
Type: checkbox

When installed, added, and activated for a particular page, and that page is linked to using the Auto-Nav, the parent page will not be linked to. Instead, the page with the lowest display order under the parent page will be linked to instead. (e.g. Click on “Locations” in a navigation, and actually link to “/locations/first-location” instead.

https://documentation.concretecms.org/user-guide/editors-reference/dashboard/pages-and-themes/attributes/built-in-attributes

I’m not sure how this is helping my situation. This will simple force a link to ‘sub item 1’ when clicked on ‘topic 1’. That is not what I want at all. It does not solve any of the two problems I have.

you could try something like this in a template

if ($ni->level == "1" && $ni->hasSubmenu) {

     echo '<li class="' . $ni->classes . ' '.$currentClicked.'">';
     echo  h($ni->name) ;

    } else if  {

     echo '<li>';
     echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . h($ni->name) . '</a>';
    
}

You could use a template we made for a site with the Elemental theme with a horizontal responsive autonav menu in the header. See https://dancestudiomaya.ch - first link (dead) «dance&rituals»

http://blink.ch/media/downloads/parent_link_disabled.zip

  1. Put the extracted folder «parent_link_disabled» into application/blocks/autonav/templates/ or alternatively YourTheme/blocks/autonav/templates/
  2. In Page Attributes, add a checkbox attribute with handle: «parent_link_disabled» and name: «Parent Link Disabled».
  3. Open your page where you want to have a dead link, add this attribute and check it.
  4. In your autonav block, apply the template «parent_link_disabled».
  5. In your header autonav, this page name is now a dead link and only subpages show or open
1 Like

A template I use:

<?php defined('C5_EXECUTE') or die("Access Denied.");
$navItems = $controller->getNavItems();

foreach ($navItems as $ni) {
	$classes = array();

	if ($ni->isCurrent) {
		$classes[] = 'nav-selected';
	}

	if ($ni->inPath) {
		$classes[] = 'nav-path-selected';
	}
	
	if ($ni->hasSubmenu) {
		$classes[] = '';
	}

	$ni->classes = implode(" ", $classes);
}

echo '<ul>';

foreach ($navItems as $ni) {

	if ($ni->hasSubmenu) {
		echo '<li>';
			
		if($ni->level == '1'){
echo ' <span class="dead">' . $ni->name . '   <span class="arrow">&#9660;</span></span>';
} else { 
		
		echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '  <span class="arrow">&#9660;</span></a>';
	}
		
		echo '<ul>'; 
		
	} else {
		echo '<li>';

	echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';
		echo '</li>';
		echo str_repeat('</ul></li>', $ni->subDepth); }

}

echo '</ul>';?>

Dev demo: https://nice.sbeech.uk/