Alternate page title in autonav in 5.6

Permalink
Hi I have just upgraded a dev site to 5.6 which is nice, however the way that the autonav now handles the controller i can't see how to adapt it to suit...

I need to have an autonav template that uses a page attribute if present rather than the page name.

I have been playing with $navItem->cObj took little luck, before i had changed the controller like so:

$altName = $tc1->getCollectionAttributeValue('page_title');
if ($altName == '') {
$niRow['cvAlternateName'] = $tc1->getCollectionAttributeValue('page_title');
} else {
$niRow['cvAlternateName'] = $tc1->getCollectionName();
}

So i tried something similar in the view template, but no luck... any ideas?

Thanks

Ben

BHWW
 
alivetech replied on at Permalink Reply
alivetech
Just had a similar issue, add this somewhere above the collection calls:
$tc1 = $navItem->cObj;
BHWW replied on at Permalink Reply
BHWW
ok so in the new controller, do you mean it should look something like this?

<?php 
   defined('C5_EXECUTE') or die("Access Denied.");
   class AutonavBlockController extends Concrete5_Controller_Block_Autonav { }
   class AutonavBlockItem extends Concrete5_Controller_Block_AutonavItem {
      $tc1 = $navItem->cObj;
      $altName = $tc1->getCollectionAttributeValue('page_title');
if ($altName == '') {   
$niRow['cvAlternateName'] = $tc1->getCollectionAttributeValue('page_title');
} else {
$niRow['cvAlternateName'] = $tc1->getCollectionName();
}}


Because i get errors with that?

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /Applications/MAMP/htdocs/www.jjf.co.uk/blocks/autonav/controller.php on line 5

Thanks for the help,

Ben
alivetech replied on at Permalink Reply
alivetech
I'm not sure why you're calling the class functions, I ended up copy the new format and using that as a starting point. Here's my code for a header nav:
<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
$navItems = $controller->getNavItems();
?>
<ul id="header_nav">
<?php  foreach ($navItems as $ni) {
   $_c = $ni->cObj;
   if ($_c->getCollectionAttributeValue('include_header_nav')) {
      $classes = array();
      if ($ni->isCurrent) {
         $classes[] = 'nav-selected';
      }
      if ($ni->inPath) {
         $classes[] = 'nav-path-selected';
      }
      if ($ni->isFirst) {


edit: Sorry to anyone who copied this code before 2013.10.15, the variable $obj clashed with the one in block_view_template.