Lurk all you'd like, but why not register and post some pics? Registering also makes it easier to find the good stuff. Need help?

Go Back   Digital Grin Photography Forum > Support > SmugMug Customization
Dgrinner
Password
Register FAQ Shooters Calendar Reviews Tutorials Gallery Books Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan-31-2006, 03:04 PM   #1
Reeves
One pixel short of sane
 
Reeves's Avatar
 
Join Date: Nov 2005
Posts: 16
Featuring my favorite pictures (featuring a keyword gallery)

Hey folks,

I wanted to have a section on my home page which featured my favorite pictures... but I didn't want to go through the labor of duplicating each picture into a new gallery to feature. After doinking with CSS for a while (and coming up very empty handed) I stumbled across devbobo's automatic "recent" featured gallery. Brilliant! As a result, I give all credit to devbobo since I really just trimmed and modified his code for this. Basically I modified devbobo's code to show a keyword gallery instead of a timeline gallery. You could, of course, use this for any keyword you choose.

You can see it in action on my site.

Note: my JS skills are minimal at best (well, I don't know JS, just C++) so I'd like to get your feedback on this tweak of David's code. It is working on my site but I may have done something silly in my futzing with the code.

I renamed the functions where appropriate to make it easier for this to coexist with the recent gallery should someone have the urge to merge them. Here's is the JavaScript code (again, copied shamelessly from devbobo):
Code:
function addKeywordFeatured(text, description, keyword, thumbUrl) { if (IsClass("homepage")) { divTag = document.getElementById("featuredBox"); if (divTag) { divTags = divTag.getElementsByTagName("div"); for (i=0; i<divTags.length; i++) { if (divTags[i].className == "boxBottom") { miniBox = document.createElement("div"); miniBox.className = "miniBox"; photoBox = document.createElement("div"); photoBox.className = "photo"; miniBox.appendChild(photoBox); photoLink = document.createElement("a"); photoLink.setAttribute("href", "/keyword/" + keyword); 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", "/keyword/" + keyword); albumTitle.appendChild(albumLink); albumLinkText = document.createTextNode(text); albumLink.appendChild(albumLinkText); albumDescription = document.createElement("p"); albumDescription.className = "description"; miniBox.appendChild(albumDescription); albumDescriptionText = document.createTextNode(description); albumDescription .appendChild(albumDescriptionText); spacerDiv = document.createElement("div"); spacerDiv.className = "spacer"; miniBox.appendChild(spacerDiv); divTags[i].insertBefore(miniBox, divTags[i].childNodes[1]); break; } } } } } function IsClass(sClass) { sClassName = document.body.className; re = new RegExp(sClass + "( |$)") if (!sClassName) return false; return re.test(sClassName); }
Also in the JS customization section I have a function to call when the page is loaded. This function triggers the keyword customization as well as other customizations I have (removed from the example for clarity).
Code:
function OnLoadHandler() { addKeywordFeatured('Favorite Pictures', 'Our favorite pictures from all our galleries.', 'Favorites', 'photos/54593627-Ti.jpg'); }

I originally used a body tag to trigger the function but devbobo pointed out that it will load more quickly if you put the onload command in the footer instead. At his recommendation I added the call to trigger the insertion via the footer instead of adding a body tag (note the asterixes should be removed):
Code:
<*script*> OnLoadHandler(); </script*>


That's about it. You can check out the results on my page.

Additional note:
The code for this customization changed at some point (possibly the server modified the code for security reasons). I've corrected the code in the post and, to make sure there is a clean copy available should it change again, I've also uploaded the script snippets here:Thanks again David (devbobo) for the code and inspiration.

Cheers,
Reeves

Last edited by Reeves : Sep-13-2006 at 07:14 AM. Reason: Correcting code
Reeves is offline   Reply With Quote
Old Jan-31-2006, 03:30 PM   #2
devbobo
technicolored
 
devbobo's Avatar
 
Join Date: Nov 2004
Location: Melbourne, AU
Posts: 4,186
Very cool Reeves...well done
__________________
David Parry
My Photos | SmugBrowser
devbobo is offline   Reply With Quote
Old Jan-31-2006, 03:33 PM   #3
Andy
Hold the meat
 
Andy's Avatar
 
Join Date: Dec 2003
Location: New York City
Posts: 50,164
And, there's a way to put that keyword gallery on your homepage

www.moonriverphotography.com

devbobo
Andy is offline   Reply With Quote
Old Jan-31-2006, 03:42 PM   #4
devbobo
technicolored
 
devbobo's Avatar
 
Join Date: Nov 2004
Location: Melbourne, AU
Posts: 4,186
Quote:
Originally Posted by Andy
And, there's a way to put that keyword gallery on your homepage

www.moonriverphotography.com

devbobo

couldn't help urself could u
__________________
David Parry
My Photos | SmugBrowser
devbobo is offline   Reply With Quote
Old Jan-31-2006, 03:56 PM   #5
Andy
Hold the meat
 
Andy's Avatar
 
Join Date: Dec 2003
Location: New York City
Posts: 50,164
Quote:
Originally Posted by devbobo
couldn't help urself could u
, no, I cannot!

I'm constantly amazed at what can be done with a SmugMug site. Thanks mucho for the hacks, David!
Andy is offline   Reply With Quote
Old Jan-31-2006, 04:05 PM   #6
Reeves
One pixel short of sane
 
Reeves's Avatar
 
Join Date: Nov 2005
Posts: 16
Okay boys... what's the noob missing? :) (was there already a way to do this?)

Quote:
Originally Posted by Andy
, no, I cannot!

I'm constantly amazed at what can be done with a SmugMug site. Thanks mucho for the hacks, David!
Reeves is offline   Reply With Quote
Old Jan-31-2006, 04:19 PM   #7
devbobo
technicolored
 
devbobo's Avatar
 
Join Date: Nov 2004
Location: Melbourne, AU
Posts: 4,186
Quote:
Originally Posted by Reeves
Okay boys... what's the noob missing? :) (was there already a way to do this?)

check out Andy's homepage, I just finished writing a hack last night that puts an album of user's choice on ur homepage in a slideshow.
__________________
David Parry
My Photos | SmugBrowser
devbobo is offline   Reply With Quote
Old Jan-31-2006, 05:22 PM   #8
Reeves
One pixel short of sane
 
Reeves's Avatar
 
Join Date: Nov 2005
Posts: 16
Quote:
Originally Posted by devbobo
check out Andy's homepage, I just finished writing a hack last night that puts an album of user's choice on ur homepage in a slideshow.

That is wicked cool! Very nice.
Reeves is offline   Reply With Quote
Old Jan-31-2006, 05:47 PM   #9
Barb
SmugMug Help Moddess
 
Barb's Avatar
 
Join Date: May 2005
Location: Boise, ID
Posts: 3,297
Quote:
Originally Posted by devbobo
check out Andy's homepage, I just finished writing a hack last night that puts an album of user's choice on ur homepage in a slideshow.

That is wonderful! It gives me an idea, but I have no clue how to do it. On my home page, would it be possible, if I removed my bio from the homepage, to have a slideshow kind of like Andy's, of a certain gallery, i.e., "Favorites", in that space? I would leave everything else alone. Does that make sense? Eesh, even after I read it, I know what I mean, but no one else may - LOL.
Barb is offline   Reply With Quote
Old Jan-31-2006, 06:37 PM   #10
devbobo
technicolored
 
devbobo's Avatar
 
Join Date: Nov 2004
Location: Melbourne, AU
Posts: 4,186
Quote:
Originally Posted by bygates
That is wonderful! It gives me an idea, but I have no clue how to do it. On my home page, would it be possible, if I removed my bio from the homepage, to have a slideshow kind of like Andy's, of a certain gallery, i.e., "Favorites", in that space? I would leave everything else alone. Does that make sense? Eesh, even after I read it, I know what I mean, but no one else may - LOL.

Hi Barb,

I am going to be writing up a tutorial on how to do this...stay tuned.

David
__________________
David Parry
My Photos | SmugBrowser
devbobo is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Dgrin Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Times are GMT -8.   It's 09:23 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.