Default autonav block not working properly with "exclude from nav" attribute and external links.

Permalink 5 0 Browser Info Environment
The default autonav block is not working properly with the "exclude from nav" attribute and external links on all browser versions.

The problem occurs if you have a top level page that you do not want to display in the navigation and that page has sub pages.

Once you set the top level page to be excluded from nav, the sub level pages will display under the next "external link" page (tab) in the navigation.

Its hard to notice unless you are using superfish.

Here is the fix.

view.php

on line 25 remove :

"if (!$_c->getCollectionAttributeValue('exclude_nav')) { "


on line 51 remove :

" }"


On line 24 under :

$_c = $ni->getCollectionObject();


add:

if ($_c->getCollectionAttributeValue('exclude_nav')) {$exclude_nav ='style="display:none!important"';}


Around line 67 replace :

if ($c->getCollectionID() == $_c->getCollectionID()) { 
            echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
         } elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && ($_c->getCollectionID() != HOME_CID) ) {
            echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
         } else {
            echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
         }


with

if ($c->getCollectionID() == $_c->getCollectionID()) { 
            echo('<li class="nav-selected nav-path-selected   " ' . $exclude_nav . ' ><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
         } elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && ($_c->getCollectionID() != HOME_CID) ) {
            echo('<li class="nav-path-selected " ' . $exclude_nav . ' ><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
         } else {
            echo('<li class="" ' . $exclude_nav . '><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
         }
Status: New

Still Valid:

This bug is valid a newer version of concrete5. View Current Bug
Hostco
View Replies:
cody121 replied on at Permalink
I have the exact same problem. But I had a hard time matching line numbers in my file, and then it also broke my styling.


This is the diff of my fix. I added the path of the page to an array, and then checked all following page to see if they were in the path of the excluded page.

--- ../../concrete/blocks/autonav/view.php 2011-10-29 11:47:59.000000000 -0700
+++ view.php 2012-02-29 20:32:43.000000000 -0800
@@ -20,9 +20,19 @@
}
}

+ $exclude = array();
foreach($aBlocks as $ni) {
$_c = $ni->getCollectionObject();
- if (!$_c->getCollectionAttributeValue('exclude_nav')) {
+ if ($_c->getCollectionAttributeValue('exclude_nav')) {
+ //Add the path of the excluded page to an array.
+ $exclude[] = $ni->getURL();
+ continue;
+ }else{
+ foreach($exclude as $excludePath){
+ //Check the path of this page against any excluded path
+ if(substr($ni->getURL(),0,strlen($excludePath)) == $excludePath)
+ {continue 2;}
+ }


$target = $ni->getTarget();
nickelfault replied on at Permalink
nickelfault
The breadcrumb template also doesn't honor the exclude from nav attribute.

Immediately following line 9, after:
$_c = $ni->getCollectionObject();


I added:
if ($_c->getCollectionAttributeValue('exclude_nav'))
     continue;


This will skip outputting the link at all rather than just hiding it using CSS.

concrete5 Environment Information

Linux
Cpanel

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0) Gecko/20100101 Firefox/10.0