|
|
Thread Tools | Display Modes |
|
#1
|
|
|
technicolored
|
Automatic "Recent" Featured Gallery using Timeline
As soon as the Timeline function appeared on smugmug, I have been thinking about automatically creating a "Recent" featured gallery on the homepage.
Here's the code to do it.. Javascript code... Code:
function addRecentFeatured(text, days, thumbUrl) {
if (YD.hasClass(document.body, "homepage")) {
divTags = YD.getElementsByClassName("boxBottom", "div", YD.get("featuredBox"));
for (i=0; i<divTags.length; i++) {
miniBox = document.createElement("div");
miniBox.className = "miniBox";
photoBox = document.createElement("div");
photoBox.className = "photo";
miniBox.appendChild(photoBox);
photoLink = document.createElement("a");
photoLink.setAttribute("href", "javascript:showRecent(" + days + ");");
photoBox.appendChild(photoLink);
photoImg = document.createElement("img");
photoImg.setAttribute("border", "0");
photoImg.setAttribute("alt", text);
photoImg.setAttribute("title", text);
photoImg.src = thumbUrl;
photoImg.className = "imgBorder";
photoLink.appendChild(photoImg);
albumTitle = document.createElement("p");
albumTitle.className = "albumTitle";
miniBox.appendChild(albumTitle);
albumLink = document.createElement("a");
albumLink.className = "nav";
albumLink.setAttribute("href", "javascript:showRecent(" + days + ");");
albumTitle.appendChild(albumLink);
albumLinkText = document.createTextNode(text);
albumLink.appendChild(albumLinkText);
spacerDiv = document.createElement("div");
spacerDiv.className = "spacer";
miniBox.appendChild(spacerDiv);
divTags[i].insertBefore(miniBox, divTags[i].childNodes[1]);
break;
}
}
}
function showRecent(days) {
endDate = new Date();
oneDay = 1000*60*60*24;
startDate = new Date(endDate.getTime() - (parseInt(days) * oneDay));
sUrl = "/date/";
sUrl += startDate.getFullYear() + "-" + padDate(startDate.getMonth() + 1) + "-" + padDate(startDate.getDate());
sUrl += "/";
sUrl += endDate.getFullYear() + "-" + padDate(endDate.getMonth() + 1) + "-" + padDate(endDate.getDate());
window.location = sUrl;
}
function padDate(datePart) {
if (datePart.toString().length != 1)
return datePart
return "0" + datePart;
}
Code:
<body onload="addRecentFeatured(text, days, thumbUrl);"> - text = title to be displayed next to feature album - days = number of days (since today) to include - thumbUrl = url of the thumbnail image eg. Code:
<body onload="addRecentFeatured('Recent Work', 60, '/photos/52382214-Ti-4.jpg');">
Cheers, David |
|
|
|
|
#2
|
|
|
I � Unicode
|
Rock on!
__________________
Y'all don't want to hear me, you just want to dance. http://photos.mikelanestudios.com/ |
|
|
|
|
#3
|
|
|
panasonikon
|
|
|
|
|
|
#4
|
|
|
technicolored
|
Thanks Andy and Mike
|
|
|
|
|
#5
|
|
|
SmugMug Hero
|
This works great. One thing that is missing is an RSS feed. I could do a lot with that. But, it appears that RSS feeds do not work with anything related to dateline searches. Bummer
__________________
If you need more help email us on the help desk here: http://help.smugmug.com Please do not PM me about help issues. About.me |
|
|
|
|
#6
|
|
|
Major grins
|
Hi,
I've just signed up for smugmug after many weeks of preparation. I love this feature but I've been having a hard time getting this code istalled. I get no errors on the javascript code itself, I've compared it to the source in devbovo js file. on the page code I noticed you're using a script on the footer instead of the <body onload...ect>. I haven't managed to get either to work. Is there any other steps I'm missing? maybe creating a gallery manually or something. thanks for the great script Jav |
|
|
|
|
#7
|
||
|
Major grins
|
I got this working after many trials. I moved the javascript call to the footer and added a featured gallery. At least for me, unless I have another featured gallery displaying this code will not display the recent featured.
So my question is, how can I have this be the only feature gallery displayed (can't make a hidden featured gallery) or can the script be changed so that the 'Recent Work' Gallery is created in another category and be called from a link in the navbar (gotorecent()~as my programming professor has a heart attack as I actualy mention using goto~). thanx Jav http://rinaldi.smugmug.com Quote:
|
|
|
|
||
|
#8
|
|
|
Big grins
|
Can I change the sorting order of this gallery? It shows my newest images last! :(
__________________
SMUGMUG SITE: http://savona.smugmug.com |
|
|
|
|
#9
|
||
|
technicolored
|
Quote:
Yes this is an undocumented feature I realised this during design, and well I was slack....i fully intended to go back and resolve this issue. But at this stage, I am snowed under at work. Cheers, David |
|
|
|
||
|
#10
|
||
|
Major grins
|
Quote:
Code:
//Goto Recent Gallery
function showRecent(days)
{
endDate = new Date();
oneDay = 1000*60*60*24;
startDate = new Date(endDate.getTime() - (parseInt(days) * oneDay));
sUrl = "/date/";
sUrl += startDate.getFullYear() + "-" + padDate(startDate.getMonth() + 1) + "-" + padDate(startDate.getDate());
sUrl += "/";
sUrl += endDate.getFullYear() + "-" + padDate(endDate.getMonth() + 1) + "-" + padDate(endDate.getDate());
window.location = sUrl;
}
function padDate(datePart)
{
if (datePart.toString().length != 1)
return datePart
return "0" + datePart;
}
//Goto Recent Gallery
Code:
<li><a href="javascript:showRecent(30)">Recent</a></li> I hope you don't mind me reusing this part of the code. I figured someone might want to try the Navbar 'recent' gallery link. Jav http://rinaldi.smugmug.com |
|
|
|
||
|
#11
|
|
|
Big grins
|
I realize you guys are busy and hate to be a pain, but, my recent images gallery shows my last image first. is there a way I can change the order so the newest image is first?
__________________
SMUGMUG SITE: http://savona.smugmug.com |
|
|
|
|
#12
|
||
|
Major grins
|
Quote:
__________________
Jav Creator of: SmugManager "There's no dark side or the moon, really. Matter of fact it's all dark..." |
|
|
|
||
|
#13
|
||
|
Big grins
|
Quote:
Mind is PHP Code:
__________________
SMUGMUG SITE: http://savona.smugmug.com |
|
|
|
||
|
#14
|
||
|
Major grins
|
Quote:
http://rinaldi.smugmug.com/date/2006-01-18/2006-02-17 this result is a 'oldest dated photo' shown first. Now since we can't reverse the order of date in the gallery, the only thing that came to my mind was reversing the date range in the url http://rinaldi.smugmug.com/date/2006-02-17/2006-01-18 alas this results in a "no photos for date range 2006-02-17 - 2006-01-18" of course because it hasn't been programmed this way. And we can't customize this virtual gallery like we do regular ones. So maybe a feature request would be to allow reversing the url, or put an extra 'leyer' of url to specify the order the photos are shown. Jav
__________________
Jav Creator of: SmugManager "There's no dark side or the moon, really. Matter of fact it's all dark..." |
|
|
|
||
|
#15
|
|
|
Beginner grinner
|
not working in FF
ok, i've got the recent pics gallery going and it works great in safari, but doesn't do anything in FireFox. Any ideas?
www.natedregerphoto.com |
|
|
|
|
#16
|
||
|
technicolored
|
Quote:
I got BWG to fix your site, you have placed the onload stuff in the wrong spot. Cheers, David |
|
|
|
||
|
#17
|
||
|
Beginner grinner
|
score, thank you.
Quote:
|
|
|
|
||
|
#18
|
||
|
Mark Coons
|
OK, David what am I overlooking here: http://musicman5.smugmug.com/
I thought I had everything in the correct place but since it doesn't appear to work I obviously do not. Plus my photo array no longer works either. Hmmm. Quote:
|
|
|
|
||
|
#19
|
|
|
could-be-thinner grinner
|
David and Jav... thank you both so much for the thought and creativity that went into this new feature... LOVE IT!
I'm going to stay subscribed to this thread to see if anyone figures out how to reverse the order, but I'm thrilled with the results as they are. Thanks again.
__________________
__________________ Stephen Skoutas http://stephenskoutas.com sskoutas@gmail.com Certe, toto, sentio nos in kansate non iam adesse Please feel free to retouch and repost my images. Critique, Suggestions, and Technique tips always welcomed. |
|
|
|
|
#20
|
|
|
could-be-thinner grinner
|
Q: Is there any way for visitors to see photos that would normally reside in password protected galleries within the recent additons gallery after they've entered their password? So many of my recent pictures are password protected that my "recent additions" gallery is a bit bare.
__________________
__________________ Stephen Skoutas http://stephenskoutas.com sskoutas@gmail.com Certe, toto, sentio nos in kansate non iam adesse Please feel free to retouch and repost my images. Critique, Suggestions, and Technique tips always welcomed. |
|
|
|
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|