Aliased page shows wrong parent in breadcrumb trail

Hi All,
I have an aliased page with a breadcrumb trail. But the breadcrumb doesn't show the parent of the aliased page, it shows the parent of the original page.

What should my auutonav code look like so my aliased page will show its parent in the breadcrumb trail?

$bt_menu = BlockType::getByHandle('autonav');
            $bt_menu->controller->orderBy = 'display_asc';
            $bt_menu->controller->displayPages = 'top';
            $bt_menu->controller->displayPagesCID = '0';
            $bt_menu->controller->displaySubPages = 'relevant_breadcrumb';
            $bt_menu->controller->displaySubPageLevels = 'enough';
            $bt_menu->controller->displaySubPageLevelsNum = '4';

View Replies:
mose replied on at Permalink Reply
Page aliases do not work the way you are thinking. An alias is not a page. An alias points to a real page elsewhere. The autonav is not on the alias. It is on the real page. When the autonav runs, then, it is running on the real page, and it finds the parent of the real page. Think of a page alias as a pair of binoculars that lets you see the real page from where you are standing. :-)
SteveAtParadigm replied on at Permalink Reply
Thanks for the reply. If you look at the url for an aliased page, it will be different from the original page. So how do I get the path info shown in the url for my aliased page to show up in my autonav?
mose replied on at Permalink Reply
It's true that the URL for the page alias is different from the original page, but that doesn't change the relationship between an alias and a page. The only job of the alias is to display the original page. That is all it does. It simply cannot do anything else.

The autonav exists on the original page. If you want the autonav to look different, then you need to go to the original page and modify the autonav there. If you go back to the alias after the change, the alias will show you how the original page now looks with the change.

So, the process is quit simple. Make the original page look just the way you want, and it will appear the exact same way in the alias.

If you are set on the alias and the original page being different, then you can't use an alias. You must use two separate pages, because two pages can be different. Copy the original page X into the location of the alias and change it to your heart's content. The autonav on the new page Y can show its parent page in the breadcrumb trail. Problem solved.

I haven't tried this, but I believe you should be able to make aliases of X's child pages and place the aliases under page Y so that they show up in Y's autonav. X and Y must be separate pages if you want the pages to be different, but they can use aliases to share the same child pages.

same = alias
different = separate
SteveAtParadigm replied on at Permalink Reply
The cID for my original page is 96,
and the alias page has a cID of 120,
and they both have different urls,
so there's got to be a way to display that difference in a breadcrumb trail.

I don't have to use an autonav, I can use whatever code works.
mose replied on at Permalink Reply
"there's got to be a way to display that difference in a breadcrumb trail."

Go to some page and create a breadcrumb trail (or any other kind of link) by hand that refers to cID=120. After you save the changes, hover over the link and see what the address is. It's the path to the original page. Just to be sure, look at the page source. It will be the path to the original page.

A page alias, then, works pretty much like "Additional Page URL(s)". You can have as many paths or aliases to a page as you want, but there is only one page, and that one page has one, true, canonical URL to access it. You want it to work this way for SEO.

An alias cannot be changed, because an alias is not a page. If you refer to an alias, you will get the original page. That is the essence of an alias.

If you want to change how a page appears in a second location, then you need a second page in that location so that it can be different from the first page.

What is it exactly that you are trying accomplish? Why is a second page not the solution?
SteveAtParadigm replied on at Permalink Reply 1 Attachment
I've got a lot of overlapping content throughout the site, and it would be helpful to be able to alias entire parts of the sitemap in different locations and at various levels. Using a global clipboard is an option, but less than ideal since I still have to make every page, and fill it with content(all-be-it global content). Since I already started making my pages with the the area-splitter block which does not support copying content to the clipboard, I'd have to remake my pages with tables, which, I'd rather not.

There is a way to get the URI using PHP and maybe I can use that to create a breadcrumb trail.

$categories = explode("/", $_SERVER['REQUEST_URI']);
echo '<ul class="breadcrumb">';
   foreach ($categories as $value) {
      echo '<li>'.$value.'</li>';
echo '</ul>';
mose replied on at Permalink Reply
I took a look at the diagram, and you won't be able to implement that with aliases.

"There is a way to get the URI using PHP and maybe I can use that to create a breadcrumb trail."

You're headed in the right direction, but that's only a small part of the story. You want a single page that always looks the same except for the breadcrumb trail. You would need to write your own autonav that generates the breadcrumb trail based on the parent the user chose to get to the page.

To find the "dynamic" parent, you would look at the referrer information. If there was no referrer for some reason (i.e., the user jumped into the middle of your website), the autonav would use the "static" or normal parent of the page.

This might do what you want, but it seems messy, because you have pages masquerading in different parts of the website. Half of the website is real, and the other half is virtual. The pages have to be responsible for knowing where they are so that they can adjust themselves accordingly.
mose replied on at Permalink Reply
I thought about this some more, and I don't think this idea will work. Concrete5 will rewrite URLs to the canonical version, which is what you want for SEO. You would be trying to defeat that feature by forcing multiple paths to appear for the same page. I don't see a solution at the moment aside from using the global scrapbook, as you have already mentioned.
SteveAtParadigm replied on at Permalink Reply
Thanks for your input on this. I've decided to copy entire parts of my sitemap with pages containing content from a global scrapbook. The copied pages will be unique, and have their own breadcrumb trail, while still containing global blocks, so I won't even have to re-paste those blocks into the copied pages. Furthermore, editing any original page block will update the copy(and vice versa).

I will have to remake a few pages using tables since the area splitter does not support scrapbooking content(just layout), but that's that.

So, all in all, I feel I've found a good solution. Thanks for providing a wall to bounce my ideas off. The site consists of 180+ pages 5 links deep of overlapping content, so you can see why some good planning and organization will save me a lot of work, and provide a better organized site for the client to edit.

BTW - Have any good tips for creating sitemaps or favorite software? I found "Inspiration 9" to be the fastest way to turn ordered lists into graphical sitemaps. is super easy, but it couldn't handle the sheer quantity of pages.
roketto replied on at Permalink Reply
Reviving an old topic here...

I'm in a very similar situation. Large site, lots of pages, duplicate page content through each section, and it goes 3 levels deep.

I was trying to achieve the same effect as Steve by aliasing pages, which would work if not for all the auto-nav's throughout the site.

Although it's not my ideal choice, it seems the global scrapbook for duplicate content is probably my best option. Thanks for hashin' this out and coming up with what seems to be the best answer.

kirkroberts replied on at Permalink Reply
Found this thread after having the same problem.
There's definitely an issue with the way the autonav controller determines the breadcrumb trail for aliased pages (at least in maybe it's fixed in 5.5), because using 'all' for displaySubPages does it correctly (for instance, if you have a drop-down menu for a main navigation). And therein lies a solution.

Change the displaySubPages and displaySubPageLevels to 'all':
$bt_links = BlockType::getByHandle('autonav');
            $bt_links->controller->displayPages = 'top';
            $bt_links->controller->orderBy = 'display_asc';                    
            $bt_links->controller->displaySubPages = 'all';
            $bt_links->controller->displaySubPageLevels = 'all';
            $bt_links->controller->displayUnavailablePages = 0;

copy the default view.php from the /concrete/blocks/autonav to /blocks/autonav/templates/breadcrumb (you may need to create the autonav and breadcrumb folders).

Then, in your newly created /blocks/autonav/breadcrumb/view.php, comment out the line that shows the pages that are not in the selected path (around line 67 of the template):
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) ) { 
            if ($i > 0) {
               print '<span class="ccm-autonav-breadcrumb-sep">></span>';
            echo('<a href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</a>');
         } else {
            // echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() . '</a>');

You can also comment out the first item (the selected page) if you don't want that to show in your breadcrumb trail.

Of course you'll also need to update the markup to display the way you want (you might not want an unordered list). There's potentially a lot you could clean out of the template, but that might be asking for trouble :-)

Hope that helps someone!
furehead replied on at Permalink Reply 1 Attachment
I had a similar problem: Autonav did not show correct path on alias pages if "relevant" pages was checked in Autonav Block.

Here is my solution: place a modified controller.php into your /blocks/autonav/controller.php

Controller.php is attached. There are some new lines beginning from line 362:

if ($this->displaySubPages == 'relevant' || $this->displaySubPages == 'relevant_breadcrumb') {
//$this->populateParentIDArray($this->cID); //Original: does not work with aliases!
/* BEGIN HACK to work with ALIAS-Pages */
   $nh = Loader::helper('navigation');
   $arrTrail = array_reverse($nh->getTrailToCollection(Page::getCurrentPage()));
   foreach($arrTrail as $i){
      $this->cParentIDArray[] = $i->cID;
/* END HACK to work with ALIAS-Pages */

This code also solves the breadcrumbs problem for aliased pages and it works for 5.5.1 and some versions below I think...
MrLindau replied on at Permalink Reply

I have the same problem in concrete5 Version
I guess the code has changed cause I can't find anything like the code you show here as a solution.

Does any one of you have the same problem with alias pages and breadcrumbs in
MrLindau replied on at Permalink Reply
I found the new autonav.php controller class in the core but even if I changed the code with the hack it did not work.
Any ideas?
adajad replied on at Permalink Reply
For future reference the fix supplied by furehead still works in 5.6.

Just make sure you override the controller correctly

   defined('C5_EXECUTE') or die("Access Denied.");
   class AutonavBlockController extends Concrete5_Controller_Block_Autonav { 
       * This function is used by the getNavItems() method to generate the raw "pre-processed" nav items array.
       * It also must exist as a separate function to preserve backwards-compatibility with older autonav templates.
       * Warning: this function has side-effects -- if this gets called twice, items will be duplicated in the nav structure!
      function generateNav() {
         if (isset($this->displayPagesCID) && !Loader::helper('validation/numbers')->integer($this->displayPagesCID)) {
         $this->displayPagesCID = 0;
         $db = Loader::db();
         // now we proceed, with information obtained either from the database, or passed manually from
         $orderBy = "";