Breadcrumb mod partly working

jecwobblejecwobble Registered Users Posts: 17 Big grins
I modified my homepage to have a slideshow separate from my galleries list. However I didn't like how the root of the breadcrumb links pointed to the slideshow (/) instead of galleries (/galleries). So to alter my breadcrumb links I wrote the following JS borrowing from the advanced tip to change "gallery comments" to "Guestbook comments" on my Guestbook gallery:
// Change root of breadcrumb trail
function ModBreadCrumb ()
{
  var objElement = YD.get("breadCrumbTrail")
  if (objElement != null) 
  {
    var str = new String(objElement.innerHTML);
    str = str.replace(/photojec.com" class/gi, 'photojec.com/galleries" class');
    str = str.replace(/John Christiansen/gi, 'JEC Photography');
    objElement.innerHTML = str;
  }
}

YE.onAvailable("breadCrumbTrail", ModBreadCrumb);

It works as desired on my gallery pages but only partially works on my category pages. The first str.replace doesn't change the HREF, but the second str.replace does change the link text. Has anybody tried to modify their breadcrumb links, and if so, how did you do it?

Comments

  • jecwobblejecwobble Registered Users Posts: 17 Big grins
    edited November 11, 2010
    Problem solved!
    Nevermind. I figured it out. The category pages have the root breadcrumb with a trailing forward slash (/) while the galleries don't. The following JS works fully on category pages now (note bold red addition):
    // Change root of breadcrumb trail
    function ModBreadCrumb ()
    {
      var objElement = YD.get("breadCrumbTrail")
      if (objElement != null) 
      {
        var str = new String(objElement.innerHTML);
        str = str.replace(/photojec.com[B][COLOR="Red"]\/?[/COLOR][/B]" class/gi, 'photojec.com/galleries" class');
        str = str.replace(/John Christiansen/gi, 'JEC Photography');
        objElement.innerHTML = str;
      }
    }
    
    YE.onAvailable("breadCrumbTrail", ModBreadCrumb);
    
  • linyangchenlinyangchen Registered Users Posts: 54 Big grins
    edited March 21, 2013
    Thank you very much for this post, three years on - I was looking for a fix for exactly this issue and here it was!

    Best regards,

    Yangchen
    where Photons meet Black Holes
    www.linyangchen.com
Sign In or Register to comment.