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?

braincramp
 
12345j replied on at Permalink Reply
12345j
To Get a Pages Description
$c->getCollectionDescription();


Display page description
<?php echo $c->getCollectionDescription() ?>

should go in view.php
braincramp replied on at Permalink Reply
braincramp
Thanks, but where would I implement this? I am putting it down where it serves up the <li> tags here:
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?
ThemeGuru replied on at Permalink Reply
ThemeGuru
Did you first of all create a description of the page via the properties tab -> attributes?
braincramp replied on at Permalink Reply
braincramp
yes, but all of the descriptions are spitting out the one for the current page, over and over for each menu item.
jbx replied on at Permalink Reply
jbx
Try $_c instead of $c

Jon
braincramp replied on at Permalink Reply
braincramp
Perfect, thanks so much!
zoinks replied on at Permalink Reply
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:

<?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")


^ 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.
normmcgarry replied on at Permalink Reply
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()
zoinks replied on at Permalink Reply
Thanks very much, I'll give it a shot.
normmcgarry replied on at Permalink Best Answer Reply
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
zoinks replied on at Permalink Reply
Thanks again for the update! I'll try that.
mdocter replied on at Permalink Reply
mdocter
The answer of @normmcgarry works. So to be fully clear, I add the final code here to get the description:

$ni->cObj->getCollectionDescription();