PDA

View Full Version : HEADS UP! Customizing Change if you use Breadcrumb JS Hack ery


Barb
Sep-25-2008, 02:22 PM
We will be changing the way our buttons work (http://www.dgrin.com/showthread.php?t=106335) shortly, and one of the hacks that some people use to change the breadcrumb will likely not work after we go live with the new stuff.

Good news, however! It's a quick fix to your current javascript to take care of the problem, and you can make the change now (and be that much further ahead of the game when the new buttons come out!).

If you are using any of the various breadcrumb hacks found on DGrin, look for it in your header or footer javascript box in your customization. This one, in particular, changes the breadcrumb to say "Home" instead of your nickname (display name). If you are using this, where it says "nickname" in the below, it will have your own nickname.

For example:

/*============================*/
/*== Change Breadcrumb ==*/
/*============================*/

var objElement = document.getElementById("breadCrumb")
if (objElement != null) {
var str = new String(objElement.innerHTML);
str = str.replace('>nickname<', '>Home<');
objElement.innerHTML = str;
}
The small change that needs to be made is in the first line, the word "breadCrumb". That needs to be changed to "breadCrumbTrail" and all should be well.


So, it would end up like this:

/*============================*/
/*== Change Breadcrumb ==*/
/*============================*/

var objElement = document.getElementById("breadCrumbTrail")
if (objElement != null) {
var str = new String(objElement.innerHTML);
str = str.replace('>nickname<', '>Home<');
objElement.innerHTML = str;
}
If you are using a breadcrumb hack that doesn't look exactly like the above, please check the one you are using to see if you need to change out the word "breadCrumb" for "breadCrumbTrail." There are a lot of variations on the code, so yours may look different.

If you have any questions at all, let us know!

pilotdave
Sep-27-2008, 04:59 PM
Should the old version now be broken and the new version working? I use code similar to that and it's working fine. Changing "breadcrumb" to "BreadCrumbTrail" causes it to fail. Should I make the change and expect it to work later, or what? pilotdave.smugmug.com

Dave

Andy
Sep-27-2008, 05:00 PM
Should the old version now be broken and the new version working? I use code similar to that and it's working fine. Changing "breadcrumb" to "BreadCrumbTrail" causes it to fail. Should I make the change and expect it to work later, or what?

Dave
What exactly are you doing on your site? What hack? Thanks!
A link would really help, thanks!

pilotdave
Sep-27-2008, 10:01 PM
What exactly are you doing on your site? What hack? Thanks!
A link would really help, thanks!

The code (in my header javascript) replaces my name in the breadcrumb with "Home". http://pilotdave.smugmug.com

If it's working fine today, is there any reason to change it?

Dave

jfriend
Sep-27-2008, 10:14 PM
The code (in my header javascript) replaces my name in the breadcrumb with "Home". http://pilotdave.smugmug.com

If it's working fine today, is there any reason to change it?

Dave

No reason I know of to change it if it's working. You do have a javascript error on every page that you should fix. In your footer, you have a function call to:

ContextualizeTitle();

but you don't have a function with that name so it's an error on every page.

npudar
Sep-28-2008, 04:54 AM
I have the following JS code (in http://photos.pudar.com) which uses the breadcrumb reference. What should I be changing now, if anything? Thanks.
Nick

//Category Description START
function addCategoryDescription() {
var categoryDescription = {
"Family" : "Family",
"Friends" : "Friends",
"Sports" : "Sports",
"Events" : "Events",
"OLS_Volleyball" : "OLS Volleyball",
"Favorites" : "Favorites"
};

if ((YD.hasClass(document.body, "category")) && (!YD.hasClass(document.body, "subcategory"))) {

re = /category_(\S+)/i;
re.exec(document.body.className);

breadCrumb = YD.get("breadcrumb");
if (breadCrumb && categoryDescription[RegExp.$1]) {
divTag = document.createElement("div");
divTag.className = "categoryDescription";
divTag.appendChild(document.createTextNode(categor yDescription[RegExp.$1]));
breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
}
}
if (YD.hasClass(document.body, "homepage")) {
re = /\>([\w\-]+)<\/a>/i;

divTag = YD.get("categoriesBox");
if (divTag) {
divTags = YD.getElementsByClassName("albumTitle", "p", divTag);

for (i=0; i<divTags.length; i++) {
re.exec(divTags[i].innerHTML);
if (categoryDescription[RegExp.$1] != undefined) {
pTag = document.createElement("p");
pTag.className = "categoryDescription";
pTag.appendChild(document.createTextNode(categoryD escription[RegExp.$1]));
divTags[i].parentNode.insertBefore(pTag, divTags[i].nextSibling);
}
}
}
}
}
YE.addListener(window, "load", addCategoryDescription);

//Category Description END

Andy
Sep-28-2008, 05:01 AM
I have the following JS code

Is all your stuff working as expected :ear

npudar
Sep-28-2008, 01:24 PM
Is all your stuff working as expected :ear

Yes, at this stage, it is working as expected. I was just curious about Barb's comment of "changing shortly" and I wanted to get ahead of the curve. So I guess my question still stands if I will need to do anything different for when the change occurs.

Thanks,
Nick

Barb
Sep-28-2008, 01:30 PM
Yes, at this stage, it is working as expected. I was just curious about Barb's comment of "changing shortly" and I wanted to get ahead of the curve. So I guess my question still stands if I will need to do anything different for when the change occurs.

Thanks,
Nick

Hi Nick,

There are many variations of breadcrumb hacks. If it's working, leave it be :)

iklimon
Oct-08-2008, 08:47 PM
I added this to my java footer:

/*=======================*/
/*== CHANGE BREADCRUMB ==*/
/*=======================*/

var objElement = document.getElementById("breadCrumbTrail")
if (objElement != null) {
var str = new String(objElement.innerHTML);
str = str.repla

And it is still showing klimonphoto in my breadcrumb. Any ideas?

:scratch

iklimon
Oct-08-2008, 08:48 PM
I added this to my java footer:

/*=======================*/
/*== CHANGE BREADCRUMB ==*/
/*=======================*/

var objElement = document.getElementById("breadCrumbTrail")
if (objElement != null) {
var str = new String(objElement.innerHTML);
str = str.repla
And it is still showing klimonphoto in my breadcrumb. Any ideas?

:scratch

And on a side note, is there any way to change where that link goes to? Like I have a 2nd homepage, can I change it to go there?

iklimon
Oct-09-2008, 08:58 AM
And on a side note, is there any way to change where that link goes to? Like I have a 2nd homepage, can I change it to go there?

Okay, found the answer to changing the link, but still cannot get the text change working.

iklimon
Oct-09-2008, 09:58 AM
Okay, found the answer to changing the link, but still cannot get the text change working.

With Allen's help I got it all working.

Here is the post that has the final code: http://dgrin.com/showpost.php?p=939738&postcount=8

Thanks!

:thumb