Tell me more ×
SmugMug Stack Exchange is a question and answer site for SmugMug developers and end users. It's 100% free, no registration required.

I want to have a description on a category page introducing the galleries it contains. Is it possible to add text to that page?

share|improve this question

1 Answer

You can if you have a power account you can. Take a look at #42 on the Most Requested Customization Tips. Here is the javascript they said to add, simply modify the "category_name:description" to match your category name and the description you want.

function addCategoryDescription() {
 var categoryDescription = {
     "category_name" : "multiple word categories are separated by an underscore",
     "category2" : "This is another test.",
      "category3" : "Final test"
 };

  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.appendChild(document.createTextNode(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[i].innerHTML);
        if (categoryDescription[RegExp.$1] != undefined) {
          pTag = document.createElement("p");
          pTag.className = "categoryDescription";
          pTag.appendChild(document.createTextNode(categoryDescription[RegExp.$1]));
          divTags[i].parentNode.insertBefore(pTag, divTags[i].nextSibling);
        }
      }
    }
  }
}
YE.addListener(window, "load", addCategoryDescription);
share|improve this answer
I feel a bit uncomfortable with a copy of code from Smugmug's FAQ being offered here as "the solution" to a problem. What happens if Smugmug needs to fix the code in the FAQ? This version doesn't get fixed and users now find the old version and use it. Isn't it safer just to reference the master location of the code rather than make a new copy that won't be maintained. – jfriend00 Jan 27 '12 at 23:36
@jfriend00 I thought about that also. Which is why I put the link also, but just in case in disappears from there, it will still be here. The best I could come up with. I didn't just want to put a link though. – jschoen Jan 28 '12 at 2:08
The link doesn't help much though because people will just copy the code from here rather than go follow the link and copy the code from there. So once this is out-of-date, folks will get out-of-date code. – jfriend00 Jan 28 '12 at 2:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.