ANSWERED: navigation breadcrumb helper

Permalink
using breadcrumb helper posted in developer docs here:

http://www.concrete5.org/documentation/developers/helpers/navigatio...

I opened up the php "page type" file located in the root of my theme, and pasted the snippet:

$nh = Loader::helper('navigation');
$breadcrumb = $nh->getTrailToCollection($c); 
krsort($breadcrumb); 
foreach ($breadcrumb as $bcpage) { 
     echo '' . $bcpage->getCollectionName() . ' > '; 
     } 
echo $c->getCollectionName();


The breadcrumbs appear as desired, but the hyperlinks are not active:

http://sacredheart.saintstephenofhungary.net/sacraments/baptism/...

Keep in mind, I have a beginner level understanding of html/css and none whatsoever of pre-processor language.

As goes without saying, any help here is greatly appreciated.

jamesfinn
 
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
You need to echo out the url as well as the collection name.
echo '<a href="' . bcpage->url . '">' . $bcpage->getCollectionName() . '</a>';
jamesfinn replied on at Permalink Reply
jamesfinn
Thank you for the reply. I updated the code by changing the last line:
<?php
         $nh = Loader::helper('navigation');
         $breadcrumb = $nh->getTrailToCollection($c); 
         krsort($breadcrumb); 
         foreach ($breadcrumb as $bcpage) { 
              echo '' . $bcpage->getCollectionName() . ' > '; 
              } 
          echo '<a href="' . bcpage->url . '">' . $bcpage->getCollectionName() . '</a>';
?>


and was greeted with the following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /homepages/9/d395545664/htdocs/SacratissimumCorJesu/packages/respond/themes/respond/respond-left-sidebar.php on line 27

obviously, all greek to me.

I could simply use the "breadcrumbs" free add-on block, but I want to learn this stuff. Once I get a grip on html/css, its on to php, mysql and js. But for the time being, I'm left to grovel in the forums.
JohntheFish replied on at Permalink Reply
JohntheFish
You are missing a $bcpage in the last line (bcpage)
jamesfinn replied on at Permalink Reply
jamesfinn
The great John the Fish. I am humbled, sir.

This thread should be subtitled "php for dummies". Because, all I understand at this point is that php is a redundant acronym.

Hence my need to ask, where do I put the "$bcpage"? Fill me in on the syntax.

Thank you for your attention.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
Like this.

<?php
         $nh = Loader::helper('navigation');
         $breadcrumb = $nh->getTrailToCollection($c); 
         krsort($breadcrumb); 
         foreach ($breadcrumb as $bcpage) { 
              echo '' . $bcpage->getCollectionName() . ' > '; 
              } 
          echo '<a href="' . $bcpage->url . '">' . $bcpage->getCollectionName() . '</a>';
?>
jamesfinn replied on at Permalink Reply
jamesfinn
thank you for your help.

as per John the Fish's notation, you added the missing $ in front of bcpage. I figured that much out on my own. I pasted John's corrected snippet into my page file. Result shown here:

http://sacredheart.saintstephenofhungary.net/sacraments/baptism/...

I am doing something wrong, no doubt.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
<?php
         $nh = Loader::helper('navigation');
         $breadcrumb = $nh->getTrailToCollection($c); 
         krsort($breadcrumb); 
         foreach ($breadcrumb as $bcpage) { 
              echo '<a href="' . $bcpage->url . '">' . $bcpage->getCollectionName() . '</a> > '; 
              } 
          echo '<a href="' . $bcpage->url . '" class="active">' . $bcpage->getCollectionName() . '</a>';
?>
jamesfinn replied on at Permalink Reply
jamesfinn
Dear Sir,

Thank you so much for looking at this for me.

your code gives me:

home > parent > parent

. . .with all three linked to the current page. Oops.

desired breadcrumbs should be:

home > parent > current child

. . .linked to their appropriate page, obviously.

current conundrum:

http://sacredheart.saintstephenofhungary.net/sacraments/baptism/...
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
<?php
$c = Page::getCurrentPage(); // You may not need this
$nh = Loader::helper('navigation');
$breadcrumb = $nh->getTrailToCollection($c); 
krsort($breadcrumb); 
foreach ($breadcrumb as $bcpage) { 
     echo '<a href="' . $bcpage->url . '">' . $bcpage->getCollectionName() . '</a> > '; 
} 
echo '<a href="' . $c->url . '" class="active">' . $c->getCollectionName() . '</a>';
?>
jamesfinn replied on at Permalink Reply
jamesfinn
Dear Scott,

that renders:

home > parent > current child

. . .but all three remain linked to the current child

here:

http://sacredheart.saintstephenofhungary.net/sacraments/anointing-s...

hmph!
ScottSandbakken replied on at Permalink Best Answer Reply
ScottSandbakken
Try this:
<?php
$c = Page::getCurrentPage(); // You may not need this
$nh = Loader::helper('navigation');
$breadcrumb = $nh->getTrailToCollection($c); 
krsort($breadcrumb); 
foreach ($breadcrumb as $bcpage) { 
     echo '<a href="' . $nh->getCollectionURL($bcpage) . '">' . $bcpage->getCollectionName() . '</a> > '; 
} 
echo '<a href="' . $nh->getCollectionURL($c) . '" class="active">' . $c->getCollectionName() . '</a>';
?>
jamesfinn replied on at Permalink Reply
jamesfinn
Scott, aka NetJunky:

Thanks a million. That's the one. Breadcrumbs are now hardcoded into my site thanks to your selfless contribution.

Godspeed!