Can somebody write me some code/script?
CynthiaM
Registered Users Posts: 364 Major grins
I hope this is the right place to post this
For days I've been searching for code regarding category and subcategory descriptions. I've been trying to make them, but with a hyperlink. I have found code that has allowed me to make the descriptions, and someone on the customization forum was able to help me get a hyperlink in the category description. But I can't get one to work in the subcategory description.
Follow this link to see the category description:
http://cynthiam.smugmug.com/Infrared
And this is the link for the subcategory description:
http://cynthiam.smugmug.com/Travel/589335
And here is the respective code. Both are loaded into the footer javascript (I don't think you can see this with the webdev tool? Only what is in the CSS?).
/*==============================*/
/* add Category descriptions */
/*==============================*/
function addCategoryDescription() {
var categoryDescription = {
"Infrared" : 'Images in these galleries were taken with a Canon Rebel XT modified for infrared photography by <a href="http://lifepixel.com/" target="_blank">Lifepixel</a>'
};
if ((YD.hasClass(document.body, "category")) && (!YD.hasClass(document.body, "subcategory"))) {
re = /category_(\S+)/i;
re.exec(document.body.className);
breadCrumb = YD.get("breadcrumb");
if (breadCrumb && categoryDescription[RegExp.$1]) {
divTag = document.createElement("div");
divTag.className = "categoryDescription";
divTag.innerHTML = categoryDescription[RegExp.$1];
breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
}
}
if (YD.hasClass(document.body, "homepage")) {
re = /\>([\w\-]+)<\/a>/i;
divTag = YD.get("categoriesBox");
if (divTag) {
divTags = YD.getElementsByClassName("albumTitle", "p", divTag);
for (i=0; i<divTags.length; i++) {
re.exec(divTags.innerHTML);
if (categoryDescription[RegExp.$1] != undefined) {
pTag = document.createElement("p");
pTag.className = "categoryDescription";
pTag.innerHTML = categoryDescription[RegExp.$1];
divTags.parentNode.insertBefore(pTag, divTags.nextSibling);
}
}
}
}
}
YE.onContentReady('bodyWrapper', addCategoryDescription);
/*==============================*/
/* the subCategory descriptions */
/*==============================*/
function addSubCatDescription() {
var SubCatDescription = {
"Alaska" : 'Click into Infrared (above) to see Alaska in Infrared'
};
if (YD.hasClass(document.body, "subcategory"))
{
re = /subcategory_(\S+)/i;
re.exec(document.body.className);
albumtitle = YD.get("subCatGalleryTitle");
if (albumtitle && SubCatDescription[RegExp.$1]) {
divTag = document.createElement("div");
divTag.className = "SubCatDescription";
divTag.appendChild(document.createTextNode(SubCatDescription[RegExp.$1]));
albumtitle.parentNode.insertBefore(divTag, albumtitle.nextSibling);
}
}
if (!YD.hasClass(document.body, "homepage")) {
re = /\>([\w\-]+)<\/a>/i;
divTag = YD.get("galleriesBox");
if (divTag) {
divTags = YD.getElementsByClassName("subCatGalleryTitle", "p", divTag);
for (i=0; i<divTags.length; i++) {
re.exec(divTags.innerHTML);
if (SubCatDescription[RegExp.$1] != undefined) {
pTag = document.createElement("p");
pTag.className = "SubCatDescription";
pTag.appendChild(document.createTextNode(SubCatDescription[RegExp.$1]));
divTags.parentNode.insertBefore(pTag, divTags.nextSibling);
}
}
}
}
}
YE.addListener(window, "load", addSubCatDescription);
The person who helped me create the hyperlink in the category description suggested that the subcategory description code may not have been written to use html. Can anyone provide me with code that can do this? I want the description to say "Click here for images of Alaska in infrared", with the word "here" being a hyperlink to this gallery:
http://cynthiam.smugmug.com/gallery/5812195_FBSN8/1/360302952_qthaT
Thanks for any help and remember I am totally out of my league here in this particular forum. The Peter Principle is definitely at play here. I admit that I have reached my level of incompetence. My breaking point is being able to copy & paste and being able to look at some code and maybe figure out that a missing or unnecessary punctuation mark is causing a problem!
Regards,
For days I've been searching for code regarding category and subcategory descriptions. I've been trying to make them, but with a hyperlink. I have found code that has allowed me to make the descriptions, and someone on the customization forum was able to help me get a hyperlink in the category description. But I can't get one to work in the subcategory description.
Follow this link to see the category description:
http://cynthiam.smugmug.com/Infrared
And this is the link for the subcategory description:
http://cynthiam.smugmug.com/Travel/589335
And here is the respective code. Both are loaded into the footer javascript (I don't think you can see this with the webdev tool? Only what is in the CSS?).
/*==============================*/
/* add Category descriptions */
/*==============================*/
function addCategoryDescription() {
var categoryDescription = {
"Infrared" : 'Images in these galleries were taken with a Canon Rebel XT modified for infrared photography by <a href="http://lifepixel.com/" target="_blank">Lifepixel</a>'
};
if ((YD.hasClass(document.body, "category")) && (!YD.hasClass(document.body, "subcategory"))) {
re = /category_(\S+)/i;
re.exec(document.body.className);
breadCrumb = YD.get("breadcrumb");
if (breadCrumb && categoryDescription[RegExp.$1]) {
divTag = document.createElement("div");
divTag.className = "categoryDescription";
divTag.innerHTML = categoryDescription[RegExp.$1];
breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
}
}
if (YD.hasClass(document.body, "homepage")) {
re = /\>([\w\-]+)<\/a>/i;
divTag = YD.get("categoriesBox");
if (divTag) {
divTags = YD.getElementsByClassName("albumTitle", "p", divTag);
for (i=0; i<divTags.length; i++) {
re.exec(divTags.innerHTML);
if (categoryDescription[RegExp.$1] != undefined) {
pTag = document.createElement("p");
pTag.className = "categoryDescription";
pTag.innerHTML = categoryDescription[RegExp.$1];
divTags.parentNode.insertBefore(pTag, divTags.nextSibling);
}
}
}
}
}
YE.onContentReady('bodyWrapper', addCategoryDescription);
/*==============================*/
/* the subCategory descriptions */
/*==============================*/
function addSubCatDescription() {
var SubCatDescription = {
"Alaska" : 'Click into Infrared (above) to see Alaska in Infrared'
};
if (YD.hasClass(document.body, "subcategory"))
{
re = /subcategory_(\S+)/i;
re.exec(document.body.className);
albumtitle = YD.get("subCatGalleryTitle");
if (albumtitle && SubCatDescription[RegExp.$1]) {
divTag = document.createElement("div");
divTag.className = "SubCatDescription";
divTag.appendChild(document.createTextNode(SubCatDescription[RegExp.$1]));
albumtitle.parentNode.insertBefore(divTag, albumtitle.nextSibling);
}
}
if (!YD.hasClass(document.body, "homepage")) {
re = /\>([\w\-]+)<\/a>/i;
divTag = YD.get("galleriesBox");
if (divTag) {
divTags = YD.getElementsByClassName("subCatGalleryTitle", "p", divTag);
for (i=0; i<divTags.length; i++) {
re.exec(divTags.innerHTML);
if (SubCatDescription[RegExp.$1] != undefined) {
pTag = document.createElement("p");
pTag.className = "SubCatDescription";
pTag.appendChild(document.createTextNode(SubCatDescription[RegExp.$1]));
divTags.parentNode.insertBefore(pTag, divTags.nextSibling);
}
}
}
}
}
YE.addListener(window, "load", addSubCatDescription);
The person who helped me create the hyperlink in the category description suggested that the subcategory description code may not have been written to use html. Can anyone provide me with code that can do this? I want the description to say "Click here for images of Alaska in infrared", with the word "here" being a hyperlink to this gallery:
http://cynthiam.smugmug.com/gallery/5812195_FBSN8/1/360302952_qthaT
Thanks for any help and remember I am totally out of my league here in this particular forum. The Peter Principle is definitely at play here. I admit that I have reached my level of incompetence. My breaking point is being able to copy & paste and being able to look at some code and maybe figure out that a missing or unnecessary punctuation mark is causing a problem!
Regards,
0