Breadcrumbs - can someone check my PHP pls?

Permalink
Hi folks!
There are a couple of top level pages on my site that I want to hide from my header nav, so I checked the 'hide from nav' in the properties - job done, great.
BUT I did want the pages to appear in the breadcrumb trail. Of course they disappeared from that as well.
I duplicated the breadcrumb template and added it to the root and searched the forum. I found a thread that mentioned looking for and removing 'exclude_nav' so I found that in my file and commented it out. Not sure if I should have taken away the { and } as well because I am not a PHP bod.
It seems to be working but I am worried that I haven't deleted all the right bits and that this may cause probs further down the line.
Please can someone check it - here is the complete code for my Breadcrumb Template (C5 version 5.4.1):
<?php  
defined('C5_EXECUTE') or die("Access Denied.");
   $aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   $nh = Loader::helper('navigation');
   $i = 0;
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      $pageLink = false;
      if ($_c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
         $subPage = $_c->getFirstChild();
         if ($subPage instanceof Page) {
         $pageLink = $nh->getLinkToCollection($subPage);
         }
      }


Thanks,
Allison

mexicanred
 
Mnkras replied on at Permalink Best Answer Reply
Mnkras
<?php 
   defined('C5_EXECUTE') or die("Access Denied.");
   $aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   $nh = Loader::helper('navigation');
   $i = 0;
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
         $pageLink = false;
         $target = $ni->getTarget();
         if ($target != '') {
            $target = 'target="' . $target . '"';
         }
         if ($_c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
            $subPage = $_c->getFirstChild();
mexicanred replied on at Permalink Reply
mexicanred
Brilliant!
Thanks Mnkras.
I thought I probably hadn't got it quite right. Hate messing with PHP unless I absolutely have to.
Cheers
Al