Autonav with descriptions
Permalink 2 users found helpful
Is there a way to get the autonav to grab page descriptions like the page list block?
Thanks, but where would I implement this? I am putting it down where it serves up the <li> tags here:
but this just repeats the description of the current page displaying the autonav.
Any advice?
if ($c->getCollectionID() == $_c->getCollectionID()) { echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" href="' . $pageLink . '">' . $ni->getName() . '<span>' . $c->getCollectionDescription() . '</span></a>'); } elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) ) { echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '">' . $ni->getName() . '<span>' . $c->getCollectionDescription() . '</span></a>'); } else { echo('<li><a href="' . $pageLink . '">' . $ni->getName() . '<span>' . $c->getCollectionDescription() . '</span></a>'); }
but this just repeats the description of the current page displaying the autonav.
Any advice?
Did you first of all create a description of the page via the properties tab -> attributes?
yes, but all of the descriptions are spitting out the one for the current page, over and over for each menu item.
Try $_c instead of $c
Jon
Jon
Perfect, thanks so much!
all the explanations I can find for AUTONAV with DESCRIPTIONS on this forum show the above type of code.
Well, the view.php template I see for Autonav looks nothing like that.
Mine looks like this:
^ how can I add Page Descriptions to that? Anyone know?
Page List will not work since they are simply not dynamic enough. This is something I need to set up in the Page Type and put on Child pages in different areas using the level above with a custom amount of 1 subpages displayed. PageList does not have that ability to do it exactly correctly (I tried every option first).
So, I need to add Page Descriptions to the default AUTONAV view.php.
Well, the view.php template I see for Autonav looks nothing like that.
Mine looks like this:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $navItems = $controller->getNavItems(); /** * The $navItems variable is an array of objects, each representing a nav menu item. * It is a "flattened" one-dimensional list of all nav items -- it is not hierarchical. * However, a nested nav menu can be constructed from this "flat" array by * looking at various properties of each item to determine its place in the hierarchy * (see below, for example $navItem->level, $navItem->subDepth, $navItem->hasSubmenu, etc.) * * Items in the array are ordered with the first top-level item first, followed by its sub-items, etc. * * Each nav item object contains the following information: * $navItem->url : URL to the page * $navItem->name : page title (already escaped for html output) * $navItem->target : link target (e.g. "_self" or "_blank")
Viewing 15 lines of 106 lines. View entire code block.
^ how can I add Page Descriptions to that? Anyone know?
Page List will not work since they are simply not dynamic enough. This is something I need to set up in the Page Type and put on Child pages in different areas using the level above with a custom amount of 1 subpages displayed. PageList does not have that ability to do it exactly correctly (I tried every option first).
So, I need to add Page Descriptions to the default AUTONAV view.php.
the $navItem is a Concrete5_Controller_Block_AutonavItem
So, you can access the Collection object using $navItem (or $ni, whatever the variable is). $ni->getCollectionObject()->getCollectionDescription()
So, you can access the Collection object using $navItem (or $ni, whatever the variable is). $ni->getCollectionObject()->getCollectionDescription()
Thanks very much, I'll give it a shot.
Nevermind. I was mistaken. It isn't an Autnavitem, even though it should be.
Check out /concrete/core/controller/blocks/autonav.php on line 650. This is the object that is used in the Autonav.
Looks like you can access it by $navItem->cObj
Check out /concrete/core/controller/blocks/autonav.php on line 650. This is the object that is used in the Autonav.
Looks like you can access it by $navItem->cObj
Thanks again for the update! I'll try that.
The answer of @normmcgarry works. So to be fully clear, I add the final code here to get the description:
$ni->cObj->getCollectionDescription();
Display page description
should go in view.php