getCollectionParentID and getCurrentPage question

Hi there,

I have a short question regarding the use of getCollectionParentID and getCurrentPage. In short what I want to achieve is a brief overview of the structure of the website. Graphically it should looks something like this:

You are here: Homepage --> News --> December 2011

My code so far only get's me the name of the current page.
<p>You are here:</p>
<a href="">
$page = Page::getCurrentPage();
echo $page->getCollectionName();

I guess I need to put a getCollectionParentID handle somewhere first and then use the getCurrentPage. I hope someone is able to help me out. I think the solution is rather simple but I just can't seem to figure it out.

Thanks in advance.

View Replies: View Best Answer
mkly replied on at Permalink Best Answer Reply
I think there might be a built in function somewhere to do this but if you are trying make a breadcrumb trail you can do this.
  $breadcrumbs = array();
  //get the page we're on and add it to the array
  $page = Page::getCurrentPage();
  $breadcrumbs[] = '<a href="' .  $this->url($page->getCollectionPath()) . '">' . $page->getCollectionName() . '</a>';
  // get the pages parent via the id
  $page = $page->getByID($page->getCollectionParentID());
  // climb up until we get a page with no parent
  while($page->getCollectionID()) {
    $breadcrumbs[] = '<a href="' . $this->url($page->getCollectionPath()) . '">' . $page->getCollectionName() . '</a>';
    $page = $page->getByID($page->getCollectionParentID());
  // flip it
  $breadcrumbs = array_reverse($breadcrumbs);
  // add the arrows

EDIT: Oops typos should work now.
GreyhorseDesign replied on at Permalink Reply
Thank you for you're anwser. You were right about the build in function. Concrete5's auto-nav comes with a breadcrum custom template. I'm still pretty new to C5 so i've overlooked that option. Still thanks for you're code snippet, appreciate it!