PDA

View Full Version : Can I delete Home link from breadCrumbTrail?


agallia
Jan-03-2009, 05:12 PM
When viewing my album pages, the breadCrumbTrail shows Home link>Gallery link>Album name. Setting a.nav to none only leaves Album name showing. But I would like to display Gallery link>Album name (no Home link). Can this be done in CSS so it looks okay? :scratch

jfriend
Jan-03-2009, 07:59 PM
It cannot be done with just CSS. You can use this Javascript to do it.

If what you want to do is to remove the top level of the breadcrumb, then you can do it by pasting this javascript into your Bottom Javascript:

YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " "); // get rid of linebreaks which cause problems for regular expressions in javascript
this.innerHTML = str.replace(/^\s*<a .*?a>.*?</i, "<");
}

agallia
Jan-03-2009, 09:29 PM
It cannot be done with just CSS. You can use this Javascript to do it.

If what you want to do is to remove the top level of the breadcrumb, then you can do it by pasting this javascript into your Bottom javascript:

YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " "); // get rid of linebreaks which cause problems for regular expressions in javascript
this.innerHTML = str.replace(/^\s*<a href=.*?&gt;\s*(&nbsp;)*\s*/, "");
} John, thanks. Just what I needed...works fine.

anonymouscuban
Jan-06-2009, 03:30 PM
AWESOME!!! This is was the icing on the cake. This was the last piece that I was missing on my site. Agallia, thanks for asking the question and jfriend, thanks for providing the code. :clap:clap:clap:clap:clap

agallia
Jan-06-2009, 03:43 PM
AWESOME!!! This is was the icing on the cake. This was the last piece that I was missing on my site. Agallia, thanks for asking the question and jfriend, thanks for providing the code. :clap:clap:clap:clap:clap Wow, Anon...! Glad to make you so happy :D. I am about where I want to be on my "simplified" site. Just a couple of other items to address. 1) putting the Search box elsewhere and 2) redoing my banner. Still thinking about separate password page as interface for password protected galleries :scratch. Yes, John is good as the rest of the SM team.

Have a good day.

anonymouscuban
Jan-06-2009, 03:46 PM
Funny... I actually just got done adding a second password protected HTML only page. I wanted to be able to seperate some of my family pictures but also archive some of the older shots so that the site is clean and fresh.

Check it out... http://www.thesotelos.com/

I too am considering changing my banner as it's something I just through together when trying the banner customization.

agallia
Jan-06-2009, 04:33 PM
Funny... I actually just got done adding a second password protected HTML only page. I wanted to be able to seperate some of my family pictures but also archive some of the older shots so that the site is clean and fresh.

Check it out... http://www.thesotelos.com/

I too am considering changing my banner as it's something I just through together when trying the banner customization. Nice, clean look! The password page fits in well. Good luck.

agallia
Jan-06-2009, 05:27 PM
Funny... I actually just got done adding a second password protected HTML only page. I wanted to be able to seperate some of my family pictures but also archive some of the older shots so that the site is clean and fresh.

Check it out... http://www.thesotelos.com/

I too am considering changing my banner as it's something I just through together when trying the banner customization.
Hi, Anon..As I said, I'm interested in making a couple of passworded pages to access private Categories. Where did you get your PW script code? How does it work?

agallia
Jan-06-2009, 06:06 PM
It cannot be done with just CSS. You can use this Javascript to do it.

If what you want to do is to remove the top level of the breadcrumb, then you can do it by pasting this javascript into your Bottom javascript:

YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " "); // get rid of linebreaks which cause problems for regular expressions in javascript
this.innerHTML = str.replace(/^\s*<a href=.*?&gt;\s*(&nbsp;)*\s*/, "");
} John, there seems to be a problem with this code. It apparently works fine in FF and Flock but not in IE or Safari. Top level still shows in those two. Is there a fix?

agallia
Jan-06-2009, 06:07 PM
AWESOME!!! This is was the icing on the cake. This was the last piece that I was missing on my site. Agallia, thanks for asking the question and jfriend, thanks for providing the code. :clap:clap:clap:clap:clap Anon...please see my post #9...

jfriend
Jan-06-2009, 06:11 PM
John, there seems to be a problem with this code. It apparently works fine in FF and Flock but not in IE or Safari. Top level still shows in those two. Is there a fix? I will look into it.

agallia
Jan-06-2009, 06:18 PM
I will look into it.Thanks.

jfriend
Jan-06-2009, 06:36 PM
John, there seems to be a problem with this code. It apparently works fine in FF and Flock but not in IE or Safari. Top level still shows in those two. Is there a fix?

That was interesting. All three browsers give you very different answers when you look at the innerHTML property. IE, reorders parameters and puts the tags in all caps. Safari no longer has HTML entities so &gt; is just > and so on. Firefox gives you the exact HTML that you put in the page.

Anyway, here's a new version that seems to work in all three browsers and I think is fairly tolerant of anything a browser might do to the HTML.

YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " "); // get rid of linebreaks which cause problems for regular expressions in javascript
this.innerHTML = str.replace(/^\s*<a .*?a>.*?</i, "<");
}

If you're curious, the regular expression is trying to get everything in the first <a>xxxx</a> sequence and then everything after that up to the start of the next HTML tag. Here's how it works:


From the beginning of the innerHTML string
Skip any whitespace that might be there
Then match on "<a " or "<A "
Then skip any amount of characters up to the first occurrence of "a>" or "A>".
Then skip any amount of characters up to the first occurrence of "<"
Then, because we matched one extra character beyond what we wanted to get rid of we put that back in the replace.
The i parameter after the regular expression tells it to be case insensitive so we can catch the fact that IE is uppercasing the tags.

agallia
Jan-06-2009, 07:12 PM
That was interesting. All three browsers give you very different answers when you look at the innerHTML property. IE, reorders parameters and puts the tags in all caps. Safari no longer has HTML entities so &gt; is just > and so on. Firefox gives you the exact HTML that you put in the page.

Anyway, here's a new version that seems to work in all three browsers and I think is fairly tolerant of anything a browser might do to the HTML.

YE.onContentReady("breadCrumbTrail", RemoveTopOfBreadCrumb);

function RemoveTopOfBreadCrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " "); // get rid of linebreaks which cause problems for regular expressions in javascript
this.innerHTML = str.replace(/^\s*<a .*?a>.*?</i, "<");
}
If you're curious, the regular expression is trying to get everything in the first <a>xxxx</a> sequence and then everything after that up to the start of the next HTML tag. Here's how it works:
From the beginning of the innerHTML string
Skip any whitespace that might be there
Then match on "<a " or "<A "
Then skip any amount of characters up to the first occurrence of "a>" or "A>".
Then skip any amount of characters up to the first occurrence of "<"
Then, because we matched one extra character beyond what we wanted to get rid of we put that back in the replace.
The i parameter after the regular expression tells it to be case insensitive so we can catch the fact that IE is uppercasing the tags. Thanks again, John. Yes, it does work in all 4 browsers but there is brief second of so in IE that Home does show before it disappears. I have code in Bottom Javascript. Would it possibly work better in Top Javascript?

jfriend
Jan-06-2009, 07:18 PM
Thanks again, John. Yes, it does work in all 4 browsers but there is brief second of so in IE that Home does show before it disappears. I have code in Bottom Javascript. Would it possibly work better in Top Javascript?

You can try it in the top javascript. Because execution is gated by the onContentReady function, it is safe either way. It might go slightly quicker there.

This is one place where IE is a little bit brain-dead. Some versions of IE will crash if you try to modify the DOM before the page has finished loading. Firefox allows it, Safari allows it. But, because IE has troubles in some situations, the YUI library has to hold off the execution of onContentReady in IE until the whole DOM is loaded. That delays the execution of your code in IE.

You may also notice that the first time you go to your site in any browser, it takes longer to load and the delay is more noticable. This is because the included JS and CSS files all have to get downloaded the first time. Until those files change, they will come out of browser cache and the delay may not be as noticable on subsequent pages.

agallia
Jan-06-2009, 07:48 PM
You can try it in the top javascript. Because execution is gated by the onContentReady function, it is safe either way. It might go slightly quicker there.

This is one place where IE is a little bit brain-dead. Some versions of IE will crash if you try to modify the DOM before the page has finished loading. Firefox allows it, Safari allows it. But, because IE has troubles in some situations, the YUI library has to hold off the execution of onContentReady in IE until the whole DOM is loaded. That delays the execution of your code in IE.

You may also notice that the first time you go to your site in any browser, it takes longer to load and the delay is more noticable. This is because the included JS and CSS files all have to get downloaded the first time. Until those files change, they will come out of browser cache and the delay may not be as noticable on subsequent pages. Didn't notice any change by moving script to Top. FF, Safari, Flock all work well but IE still has the lag. Guess I will just live with it for now and wish IE users well. Thanks very much.