Display Parent Page in Autonav
Permalink 1 user found helpful
Hi Everyone,
I'm a little bit stuck. I want to add the parent page too my customized Autonav block seen here:http://logisticadev.net/resources/...
On the left it displays the subpages for Resources but I'd like it to display the link for the resources page link too.
I used the following code found in another post:
But it just displays HOME
I've got as far as putting the custom template code in the /blocks/autonav/templates/ and applied my own styles. 95% done. It would be nice to show the parent page too.
Thanks
I'm a little bit stuck. I want to add the parent page too my customized Autonav block seen here:http://logisticadev.net/resources/...
On the left it displays the subpages for Resources but I'd like it to display the link for the resources page link too.
I used the following code found in another post:
$page = Page::getByID($c->getCollectionParentID()); print $page->getCollectionName();
But it just displays HOME
I've got as far as putting the custom template code in the /blocks/autonav/templates/ and applied my own styles. 95% done. It would be nice to show the parent page too.
Thanks
Try this:
$parentPage = Page::getByID($c->getCollectionParentID()); echo '<a href="../">' . $parentPage->getCollectionName() . '</a>';
Cherrycake is correct. You can use $_c in stead of $c (so an underscore between the dollar sign and the letter c) to get what you want. For example:
$_c->getCollectionParentID();
$_c->getCollectionParentID();
If you see HOME, it means you're currently viewing /resources/. If you click on a subpage, you should see Resources instead of home since you're currently viewing /resources/subpage.
Instead i would try and look for whatever object is used in your template to retrieve it's child pages, cause that object would obviously be the Resources collection. Then just before the iteration starts, use that object to call getCollectionName();
Hope that helps.