|
|
Thread Tools | Display Modes |
|
#1
|
|
|
One pixel short of sane
|
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);
}
Code:
function OnLoadHandler()
{
addKeywordFeatured('Favorite Pictures', 'Our favorite pictures from all our galleries.', 'Favorites', 'photos/54593627-Ti.jpg');
}
Code:
<*script*>
OnLoadHandler();
</script*>
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:
Cheers, Reeves Last edited by Reeves; Sep-13-2006 at 06:14 AM. Reason: Correcting code |
|
|
|
|
#2
|
|
|
technicolored
|
Very cool Reeves...well done
![]()
|
|
|
|
|
#3
|
|
|
panasonikon
|
And, there's a way to put that keyword gallery on your homepage
![]() www.moonriverphotography.com devbobo
|
|
|
|
|
#4
|
||
|
technicolored
|
Quote:
|
|
|
|
||
|
#5
|
||
|
panasonikon
|
Quote:
, no, I cannot!I'm constantly amazed at what can be done with a SmugMug site. Thanks mucho for the hacks, David! |
|
|
|
||
|
#6
|
||
|
One pixel short of sane
|
Okay boys... what's the noob missing? :) (was there already a way to do this?)
Quote:
|
|
|
|
||
|
#7
|
||
|
technicolored
|
Quote:
|
|
|
|
||
|
#8
|
||
|
One pixel short of sane
|
Quote:
|
|
|
|
||
|
#9
|
||
|
SmugMug Hero Captain
|
Quote:
|
|
|
|
||
|
#10
|
||
|
technicolored
|
Quote:
I am going to be writing up a tutorial on how to do this...stay tuned. David |
|
|
|
||
|
#11
|
||
|
panasonikon
|
Quote:
|
|
|
|
||
|
#12
|
||
|
SmugMug Hero Captain
|
Quote:
![]()
|
|
|
|
||
|
#13
|
||
|
SmugMug Hero Captain
|
Quote:
|
|
|
|
||
|
#14
|
||
|
SmugMug Hero Captain
|
Quote:
|
|
|
|
||
|
#15
|
||
|
One pixel short of sane
|
Quote:
|
|
|
|
||
|
#16
|
||
|
SmugMug Hero Captain
|
Quote:
|
|
|
|
||
|
#17
|
|
|
Big grins
|
Home - slideshow
Andy,
Where can I find info how to implement a slideshow like you have on your homepage? (www.moonriverphotography.com_) Thanks in advance! Julian |
|
|
|
|
#18
|
||
|
Major grins
|
Quote:
|
|
|
|
||
|
#19
|
|
|
Big grins
|
Got it working, almost flawlessly...
Now for the head scratcher: The behavior when displaying horizontal vs vertical pictures gives some strange behavior, at least in IE 6. Seems the large picture of the thumbnail (displayPhoto), when horizontal goes to the bottom of the page. When you try to scroll down, IE just sort of jiggles but does not move unless you use the scroll bar. In my other galleries, the style of the display photo is such that it fits beside the thumbs. I also note the thumbnail overlaps the text in firefox on the created gallery. I guess there is something not getting set somewhere. More on the customization angle, how do you get Guess I'll need "professional help" to fix this one. Is this some of this sort of thing going into the How To that is in the works? Thanks to all who work on this stuff! www.wildstate.com is the site, btw Evidently, I didn't make it clear where the "featured gallery" with keywords is located, it is located at www.wildstate.com, my smugmug site.
__________________
Wildlife & Nature Photography Last edited by Redskeeter; Feb-25-2006 at 10:19 AM. |
|
|
|
|
#20
|
|||
|
I � Unicode
|
Quote:
Quote:
__________________
Y'all don't want to hear me, you just want to dance. http://photos.mikelanestudios.com/ |
||
|
|
|||
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|