getFirstChild as Page title
Permalink 2 users found helpful|Home
|-Page 1
|--Subpage 1
|--Subpage 2
|-Page 2
|--Subpage 3
|--Subpage 4
When you are on Page 1, Subpage 1 or Subpage 2 - Page 1 would be returned between the h3 tags.
When you are on Page 2, Subpage 3 or Subpage 4 - Page 2 would be returned between the h3 tags.
I've tried variations on the below with no avail, any help greatly appreciated.
Regards
Would it be simple to add an <a href=""> to that code to link to the page whose text one is displaying?
<?php $title = $c->getCollectionName(); $parentPageId = $c->getCollectionParentID(); if ($parentPageId > 1) { $parentPage = Page::getById($parentPageId); $title = $parentPage->getCollectionName(); $url = View::URL($parentPage->getCollectionPath()); } else { $url = DIR_REL; } ?> <h3><a href="<?php echo $url; ?>"><?php echo $title; ?></a></h3>
Thanks for your reply, that works for sub pages but if it's on the main page it return you to the top level (home) page rather than just reloading the current page, It will work for what I need, but just so you know it's not quite right.
Thank you
http://www.concrete5.org/index.php?cID=56694...
The reason this works is because the home page's id is always 1, and the home page's parent id is always 0 (because there isn't one). So if you check the current page's parent id and it's 0, then you're on the home page; if it's 1, then you're on a sub-page. But if it's anything else, you're on a sub-sub-page, in which case you grab the title of the parent page.
Hope that helps!
-Jordan