page aliases and the autonav block

Permalink
Just posted a site with a top level page —http://www.rosekennedygreenway.org/donate/... — that is aliased to a subpage in another section:http://www.rosekennedygreenway.org/get-involved/donate/...

If you click on the second link you'll notice that TWO top level items are now highlighted, as they both get nav-selected / nav-path-selected classes in the autonav. Ideally I'd like JUST the original page to be highlighted, even if the alias is clicked, but I can't quite get my head around how to accomplish this.

The alias has its own URL even though it displays the original page (which is technically at a different URL). Yet the autonav in the sidebar shows as if its on the original page. This is confusing to me.

I'd like to have the aliases in the autonav simply point to the original page, as if the viewer clicked on the original page's nav item. Tried using an external link and hard-coding the URL, but that won't work in this situation (need some page attributes from the original page).

Seems like there must be an elegant solution to this, but I'm flummoxed. Can anyone help me with this?

kirkroberts
 
kirkroberts replied on at Permalink Reply
kirkroberts
I'm surprised this hasn't gotten *any* response. Is it just not possible?

I guess I'll have to compromise and copy the page and have it redirect to the original. Seems like an unnecessary word-around... I'd much rather update my auto-nav custom template somehow to handle ALL aliases (have them redirect to the original page.

Perhaps there is a way to determine which Collection this Page is aliased to? I've looked at the API and found the isAlias() function, but no way of seeing where the alias points to...
kirkroberts replied on at Permalink Best Answer Reply
kirkroberts
Alright, I got this working!

Basically, I determined the path (eg /path/to/page) and ID (eg 72) of the current page (that is showing in the browser).

Then, in the loop, I compared those with the currently iterating item in the navigation.
If both the IDs AND paths of the current page and nav item match, apply the nav-path-selected and nav-selected classes.
If the nav item is in the $selectedPathCIDs AND the IDs of the current page and nav item do NOT match, apply the nav-path-selected class.

Hope that helps someone!

EDIT :: code that should do the trick (mine was different... but this is simpler to show)

In an auto-nav template there is this code:
<?php
if ($c->getCollectionID() == $_c->getCollectionID()) { 
   echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
} elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) ) { 
   echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
} else {
   echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
}
?>

replace that with
<?php
if ($c->getCollectionID() == $_c->getCollectionID() && $c->cPath == $_c->cPath) { 
   echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
} elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && $c->getCollectionID() != $_c->getCollectionID()) { 
   echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
} else {
   echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');
}
?>

and only the actual page path will be selected in your navigation (not aliases or original pages if the selected page is an alias).