View Full Version : Date Breadcrumb
Spiffyman
Mar-15-2009, 04:29 AM
Want the breadcrumb in the recently added pages, using this code for displaying recent list: http://www.dgrin.com/showthread.php?t=105824
Have the javascript code in to replace the nickname with the main gallery page - works fine everywhere except the recently added, where it continues to display the nickname as the first link in the breadcrumb.
Any idea why?
http://www.abouttowneimagery.com/
Spiffyman
Mar-15-2009, 05:02 AM
Looking more in to this, actually an interesting little issue. Is seems that when you run a timeline query (say by a specific year), the resulting page is half back-end smug mug, have customized from the individual site.
So in this case, the first link in the breadcrumb is the site nickname rather than the galley as I have specified in my javascript settings.
jfriend
Mar-15-2009, 08:29 AM
Want the breadcrumb in the recently added pages, using this code for displaying recent list: http://www.dgrin.com/showthread.php?t=105824
Have the javascript code in to replace the nickname with the main gallery page - works fine everywhere except the recently added, where it continues to display the nickname as the first link in the breadcrumb.
Any idea why?
http://www.abouttowneimagery.com/
Since I wrote the JS that you are using to modify the breadcrumb, I took a look at what is happening. This has nothing to do with your other issue. The fact is that the breadCrumbTrail object has very different HTML in it than anywhere else and the code you have is not prepared to handle that different looking HTML. Thus, it fails to find the match it's looking for and doesn't change your breadcrumb. I'll have to figure out the best way to make the code still work here and do everything else it does and keep it simple.
Spiffyman
Mar-15-2009, 08:56 AM
Since I wrote the JS that you are using to modify the breadcrumb, I took a look at what is happening. This has nothing to do with your other issue. The fact is that the breadCrumbTrail object has very different HTML in it than anywhere else and the code you have is not prepared to handle that different looking HTML. Thus, it fails to find the match it's looking for and doesn't change your breadcrumb. I'll have to figure out the best way to make the code still work here and do everything else it does and keep it simple.
Thanks John - sometimes it is easy to come to the "kitchen sink" approach. Appreciate your help here.
BTW, they should make you a moderator - you are SO responsive and helpful !!!!!
jfriend
Mar-15-2009, 09:36 AM
Thanks John - sometimes it is easy to come to the "kitchen sink" approach. Appreciate your help here.
BTW, they should make you a moderator - you are SO responsive and helpful !!!!!
Here's an improved version of the code that should handle that page. But, I can't seem to get my own site to generate the kind of page you have so I can't test it exactly on my own site. Let me know if this works or needs more refinement.
Remove this older version of the code:
function AdjustBreadcrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " ");
str = str.replace(/^\s*<a .*?<\/a>/i, '<a href="/galleries" class="nav">Galleries</a>');
this.innerHTML = str;
}
YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);
Add this new version of the code:
function GetUserTopPage()
{
if (window.webServer && (window.webServer != ""))
{
return(window.webServer);
}
if (window.smugmugUserHomepage && (window.smugmugUserHomepage != ""))
{
return(window.smugmugUserHomepage);
}
return("");
}
function AdjustBreadcrumb()
{
var str = this.innerHTML;
str = str.replace(/\n/g, " ");
str = str.replace(/^\s*(<div.*?<\/div>)?\s*<a .*?<\/a>/i, '<a href="' + GetUserTopPage() + '/galleries" class="nav">Galleries</a>');
this.innerHTML = str;
}
YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);
Spiffyman
Mar-15-2009, 09:53 AM
Looks good!
Thanks
jfriend
Mar-15-2009, 09:55 AM
Looks good!
Thanks Oops, the version of the code I gave you had a debugging statement still in it. I've edited my previous post to take that out. You should update the code one more time.
Spiffyman
Mar-15-2009, 10:25 AM
Changed - thanks again
jfriend
Mar-16-2009, 12:04 AM
Changed - thanks againI found a few more problems with the version of this script that you installed. The latest version which is more robust in search and in communities is here:
// Script to change the breadcrumb link to your homepage to point to your galleries page instead of your slideshow
// It also changes that link to say "Galleries" instead of your user name
function AdjustBreadcrumb()
{
// there are something like six different forms of the breadcrumb including search and keyword and date and communities, categories and galleries that we have to make this work for
var tags = YD.getElementsByClassName("nav", "a", this); // get all the <a> tags with class "nav"
var filteredTags = new Array;
// filter out any that aren't at the top level in the breadCrumbTrail (this gets rid of the relatedDate tags)
for (var i in tags)
{
if (tags[i].parentNode == this)
{
filteredTags.push(tags[i]);
}
}
if (filteredTags.length == 0)
{
return;
}
// default to targeting the first filtered tag
var targetTag = filteredTags[0];
// see if we have a community here
if (filteredTags.length > 1)
{
// if we have a community here, then the user top level is in the 2nd position
if (filteredTags[0].href.search(/\/community\//) != -1)
{
targetTag = filteredTags[1];
}
}
// make sure URL ends with a slash
var str = targetTag.href;
if (str.search(/\/$/) == -1)
{
str += "/";
}
str +="galleries";
targetTag.href = str;
targetTag.innerHTML = "Galleries";
}
YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.