• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug Customization Automatic "Recent" Featured Gallery using Timeline

FAQtoid

Ever wanted to create an Avatar? Creating an Avatar!

Searching Dgrin with Google Searching with Google

Dgrin Challenges

Congratulations to the Winner of DSS #128 (Sunrise or Sunset), ShootingStar.

The next Dgrin Challenge DSS #129 (Silhouette Revisited ) is open for entries through May 27th, 2013 at 8:00pm PDT.

As always, we look forward to your participation but please do take a moment to read through the rules before posting your entry.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Need some help with Accessories?

Tutorials

Ever find yourself wondering just how someone managed to create an image using different effects?

Here are three simple tutorials we hope will encourage you to try something new.

The Hot Seat

A lifelong interest in landscape photography has led Eyal Oren to make a study of his adopted hometown of Marblehead, MA. As you can see, his dedication is paying off!

Africa!

Dgrinners Harryb, Pathfinder, and others joined Andy Williams and Marc Muench on Safari in East Africa recently. Here are some awesome threads to check out!

 
Thread Tools Display Modes
Page 1  of  3
1 2 3
Old Jan-30-2006, 04:57 AM
#1
devbobo is offline devbobo OP
technicolored
devbobo's Avatar
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;
}
To run this function, add the following to the body tag code...

Code:
<body onload="addRecentFeatured(text, days, thumbUrl);">
where
- 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');">
You can check it out here

Cheers,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Jan-30-2006, 05:55 AM
#2
Mike Lane is offline Mike Lane
I � Unicode
Mike Lane's Avatar
Rock on!
__________________
Y'all don't want to hear me, you just want to dance.

http://photos.mikelanestudios.com/
Old Jan-30-2006, 06:27 AM
#3
Andy is offline Andy
panasonikon
Andy's Avatar
__________________
Andy
Moon River PhotographyWorkshopsGoogle+FacebookTwitter
Old Jan-30-2006, 11:47 AM
#4
devbobo is offline devbobo OP
technicolored
devbobo's Avatar
Thanks Andy and Mike
__________________
David Parry
SmugMug API Developer
My Photos
Old Feb-01-2006, 05:19 AM
#5
docwalker is offline docwalker
SmugMug Hero
docwalker's Avatar
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
Old Feb-11-2006, 06:35 AM
#6
javier.rinaldi is offline javier.rinaldi
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
Old Feb-13-2006, 06:01 AM
#7
javier.rinaldi is offline javier.rinaldi
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:
Originally Posted by javier.rinaldi
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
Old Feb-13-2006, 06:29 PM
#8
Savone is offline Savone
Big grins
Can I change the sorting order of this gallery? It shows my newest images last! :(
__________________
SMUGMUG SITE: http://savona.smugmug.com
Old Feb-13-2006, 07:38 PM
#9
devbobo is offline devbobo OP
technicolored
devbobo's Avatar
Quote:
Originally Posted by javier.rinaldi
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
Hi Jav,

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
__________________
David Parry
SmugMug API Developer
My Photos
Old Feb-14-2006, 06:28 AM
#10
javier.rinaldi is offline javier.rinaldi
Major grins
Quote:
Originally Posted by devbobo
Hi Jav,

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
Well since I use a navbar for most of my stuff, and that's where I wanted a link to the 'Recent' gallery I took a look at the code and pretty much kept the date functions

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
then I placed the following into the navbar html
Code:
<li><a href="javascript:showRecent(30)">Recent</a></li>
Works great since the recent gallery is just a /date/YYYY-MM-DD/YYYY-MM-DD string added to the url.

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
Old Feb-16-2006, 01:17 PM
#11
Savone is offline Savone
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
Old Feb-16-2006, 01:50 PM
#12
javier.rinaldi is offline javier.rinaldi
Major grins
Quote:
Originally Posted by Savone
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?
I looked into mine, it does the same. I guess it's the way the range is defined, you can't reverse it by changing the url to "end date"/"start date", so maybe this is something to put in requested features.
__________________
Jav


Creator of: SmugManager

"There's no dark side or the moon, really. Matter of fact it's all dark..."
Old Feb-17-2006, 02:33 AM
#13
Savone is offline Savone
Big grins
Quote:
Originally Posted by javier.rinaldi
I looked into mine, it does the same. I guess it's the way the range is defined, you can't reverse it by changing the url to "end date"/"start date", so maybe this is something to put in requested features.
I dont understand, can you clarify that statement? Or maybe give me an example URL?

Mind is
PHP Code:
<a href="javascript:showRecent(35);">Recent Additions</a
__________________
SMUGMUG SITE: http://savona.smugmug.com
Old Feb-17-2006, 03:21 AM
#14
javier.rinaldi is offline javier.rinaldi
Major grins
Quote:
Originally Posted by Savone
I dont understand, can you clarify that statement? Or maybe give me an example URL?

Mind is
PHP Code:
<a href="javascript:showRecent(35);">Recent Additions</a
I use the same function, the result url for me is:

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..."
Old Oct-29-2006, 01:20 PM
#15
natedreger is offline natedreger
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
Old Oct-30-2006, 02:29 AM
#16
devbobo is offline devbobo OP
technicolored
devbobo's Avatar
Quote:
Originally Posted by natedreger
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
Nate,

I got BWG to fix your site, you have placed the onload stuff in the wrong spot.

Cheers,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-30-2006, 04:23 PM
#17
natedreger is offline natedreger
Beginner grinner
score, thank you.

Quote:
Originally Posted by devbobo
Nate,

I got BWG to fix your site, you have placed the onload stuff in the wrong spot.

Cheers,

David
Old Jun-15-2007, 07:56 AM
#18
mrcoons is offline mrcoons
Mark Coons
mrcoons's Avatar
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:
Originally Posted by devbobo
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;
}
To run this function, add the following to the body tag code...

Code:
<body onload="addRecentFeatured(text, days, thumbUrl);">
where
- 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');">
You can check it out here

Cheers,

David
__________________
Mark
------
Smugmug site
Blog Portfolio
Facebook
Old Jun-15-2007, 08:21 AM
#19
sskoutas is offline sskoutas
could-be-thinner grinner
sskoutas's Avatar
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.
Old Jun-15-2007, 06:13 PM
#20
sskoutas is offline sskoutas
could-be-thinner grinner
sskoutas's Avatar
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.
Page 1  of  3
1 2 3
Tell The World!  

Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump