Redirect Child Page to Parent Page in Auto Nav

Permalink
I want to redirect child page to parent page in the auto nav
More detail.

Product(Parent Page)
-- Item1(Child) (need-> url(parent page url)
-- Item2(Child) (need-> url(parent page url)

 
mnakalay replied on at Permalink Best Answer Reply
mnakalay
In your autonav, you can get the page object from

$pageObject = $ni->cObj;

Once you have that you can get the parent ID and from there the parent page object
$parentID = $pageObject->getCollectionParentID();
$parentPageObject = Page::getByID($parentID);

Once you have the parent page object, you get the URL like this
$parentUrl = $parentPageObject->getCollectionLink();


Out of curiosity, why would you want to redirect a child page to its parent? That renders the child page pretty useless, why have it in the first place?