breadcrumbs display hidden pages "exclude from nav"
Permalink 1 user found helpful
Hi
I have an auto_nav menu structure that has several "exclude from nav" or hidden pages.
I also have breadcrumb navigation, is it possible to override the "exclude from nav" so that all the parent pages are displayed in one menu but not the other?
thanks for any pointers
I have an auto_nav menu structure that has several "exclude from nav" or hidden pages.
I also have breadcrumb navigation, is it possible to override the "exclude from nav" so that all the parent pages are displayed in one menu but not the other?
thanks for any pointers
i used this as an auto_nav template file ..
Viewing 15 lines of 35 lines. View entire code block.
I have found that in these situations it is best to create an attribute like 'include_main_nav'
Then in your autonav block instead of this line
use this
Then in your autonav block instead of this line
if (!$_c->getCollectionAttributeValue('exclude_nav')) {
use this
if ($_c->getCollectionAttributeValue('include_main_nav')) {
I added this issue to the bug tracker:
http://www.concrete5.org/developers/bugs/5-4-1-1/breadcrumbs-do-not...
so please confirm the bug there, that it get changed in c5 core
http://www.concrete5.org/developers/bugs/5-4-1-1/breadcrumbs-do-not...
so please confirm the bug there, that it get changed in c5 core
I also ran into this problem today. I solved it by overriding the getNavItems function from the AutonavBlockController.
First locate the following code:
Directly after this code insert the following code:
Then locate this code block:
And replace it with this code:
This works, though I think it's not ideal. If you have a second breadcrumb template you would have to edit the controller code again. Best would be if two checkboxes would be added in the edit view of the autonav block to be able to ignore the exclude_subpages_from_nav and exclude_nav page attribute.
First locate the following code:
//Retrieve the raw "pre-processed" list of all nav items (before any custom attributes are considered) $allNavItems = $this->generateNav();
Directly after this code insert the following code:
$db = Loader::db(); $bFilename = $db->getOne("SELECT bFilename FROM Blocks WHERE bID = ? " , array($this->bID) ); $breadcrumb = $bFilename == 'breadcrumb.php'; //you could add more or another template filename here.
Then locate this code block:
if ($_c->getAttribute('exclude_nav') && ($current_level <= $excluded_parent_level)) { $excluded_parent_level = $current_level; $exclude_page = true; } else if (($current_level > $excluded_parent_level) || ($current_level > $exclude_children_below_level)) { $exclude_page = true; } else { $excluded_parent_level = 9999; //Reset to arbitrarily high number to denote that we're no longer excluding a parent $exclude_children_below_level = $_c->getAttribute('exclude_subpages_from_nav') ? $current_level : 9999; $exclude_page = false; }
And replace it with this code:
if ($_c->getAttribute('exclude_nav') && ! $breadcrumb && ($current_level <= $excluded_parent_level)) { $excluded_parent_level = $current_level; $exclude_page = true; } else if (($current_level > $excluded_parent_level) || ($current_level > $exclude_children_below_level)) { $exclude_page = true; } else { $excluded_parent_level = 9999; //Reset to arbitrarily high number to denote that we're no longer excluding a parent $exclude_children_below_level = $_c->getAttribute('exclude_subpages_from_nav') && ! $breadcrumb ? $current_level : 9999; $exclude_page = false; }
This works, though I think it's not ideal. If you have a second breadcrumb template you would have to edit the controller code again. Best would be if two checkboxes would be added in the edit view of the autonav block to be able to ignore the exclude_subpages_from_nav and exclude_nav page attribute.
I ran into this issue too. I tried your code but I'm getting the following error
I added the code you provided to the controller file of the autonav block. Thank you in advance for any help you can provide.
Fatal error: Using $this when not in object context in /concrete/blocks/autonav/controller.php on line 6
I added the code you provided to the controller file of the autonav block. Thank you in advance for any help you can provide.
Hi, there. I see I wasn't quite clear about where to insert the modifications. I edited my solution a little, hope this clears things up.
Also, make sure you overwrite the controller function like this:
1. Copy the file /concrete/blocks/autonav/controller.php to /blocks/autonav/controller.php
2. Copy the function getNavItems() from /concrete/core/controllers/blocks/autonav.php to the AutonavBlockController Class in /blocks/autonav/controller.php
Then make the modifications in that function as described in my previous post.
Let me know if you need more help!
Also, make sure you overwrite the controller function like this:
1. Copy the file /concrete/blocks/autonav/controller.php to /blocks/autonav/controller.php
2. Copy the function getNavItems() from /concrete/core/controllers/blocks/autonav.php to the AutonavBlockController Class in /blocks/autonav/controller.php
Then make the modifications in that function as described in my previous post.
Let me know if you need more help!
Thank you for the quick reply. I have followed the steps but the pages I want to exclude are still showing in the breadcrumb. I'm thinking it might be partly do to my file organization. I keep all my templates in the root /blocks folder, and each theme has its' own folder, e.g. /blocks/autonav/templates/breadcrumb_simple/view.php . I also put the new controller file in this breadcrumb_simple folder. Will this type of organization not work with this line of code?
I have also attached my edited controller.php file, just to make sure I executed it properly.
$breadcrumb = $bFilename == 'breadcrumb_simple/view.php';
I have also attached my edited controller.php file, just to make sure I executed it properly.
You'll have to move the getNavItems function inside the AutonavBlockController class. The file structure should look like this:
I think 'breadcrumb_simple/view.php' is correct in your case. If it still won't work simply echo the $bFilename variable right after where it's set and check the block output on the page:
I think 'breadcrumb_simple/view.php' is correct in your case. If it still won't work simply echo the $bFilename variable right after where it's set and check the block output on the page: