How to hide the Galleries of a Category on Home Page

jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
Allen suggested I post this here. I hope someone can point me in the right direction...

Much like hiding Galleries on the homepage, I'd like to set the Galleries Display: to galleries instead of categories, and I'd like all of the galleries from designated categories to not be displayed in the list of galleries.

I tried to tweak the "hide categories" javascript to no avail. Does anyone know how to accomplish this?

Is there a SM javascript expert out there that may know how to do this? I think it's possible -- I'm just not that proficient with javascript yet. If you could just get pointed in the right direction I'd appreciate it.

I posted earlier in a differnet thread but no one responded (http://www.dgrin.com/showthread.php?t=48082&page=5). Thanks in advance for helping out.

Comments

  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 10, 2008
    What's the name of the javascript function that populates the list of galleries in the homepage/galleries page galleries box? That's probably a good place to start.
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 11, 2008
    Bump please
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 18, 2008
    Can someone please help get me started on this? headscratch.gif Please take a look at my site:
    http://www.nikiwalkerphotography.com/galleries

    I'd like to not have the Portfolio"n" galleries appear in the Galleries box, and don't want to hide them either. Thanks.
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 22, 2008
    OK, I got started on my own. I slightly modified the delCategory function so it deletes galleries instead of categories. Works great. Can't do it by category, but I don't mind listing all the galleries.

    Now the second challenge: How can I have this happen just on the homepage and not a category page?

    function delGallery() {
    re = /\/(5144046_32NsP|5144110_myhEX)$/;

    var oList = YD.getElementsByClassName('miniBox', 'div', this);

    for (i = 0; i < oList.length; i++) {
    if (re.test(oList.getElementsByTagName('a')[0].href))
    oList.parentNode.removeChild(oList);
    }
    }
    YE.onContentReady('galleriesBox', delGallery);
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited June 22, 2008
    jwalkeroh wrote:
    Now the second challenge: How can I have this happen just on the homepage and not a category page?

    Add this...
    function delGallery() {
      if(!YD.hasClass('homepage', document.body))
        return;
    
      re = /\/(5144046_32NsP|5144110_myhEX)$/;
    
    David Parry
    SmugMug API Developer
    My Photos
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 23, 2008
    devbobo wrote:
    Add this...
     
    function delGallery() {
      if(!YD.hasClass('homepage', document.body))
        return;
     
      re = /\/(5144046_32NsP|5144110_myhEX)$/;
    

    WOW, you are THE MAN. (except the syntax is (element, className), so I coded it as follows and it works great):

    function delGallery() {
    if(!YD.hasClass(document.body, 'homepage'))
    return;

    re = /\/(5144046_32NsP|5144110_myhEX)$/;

    Now the third and final challenge: Is there any way to code this so I can list the "categories" to delete in the "re =" list instead of the "galleries"? In this case all of the galleries listed are in the same category, so it would be easier to maintain the list if by category.

    Thanks for the snippet. Just what I needed.

    (PS: Wonder if you could also take a peek at the problem I'm having here:
    http://www.dgrin.com/showpost.php?p=856259&postcount=9
    )
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 24, 2008
    I changed my Footer Javascript slightly to a) overcome having galleries disappear form the homepage when loggedIn, and to hide all empty galleries.
    Here's the updated Javascript:

    // Delete certain galleries from the galleriesBox, meeting the following criteria:
    // a) None when loggedIn.
    // b) The galleries listed in the "re" variable, but only on the homepage.
    // c) All empty galleries.
    // The specific intent here is to delete from the homepage galleriesBox, all of the
    // galleries for a certain category. In this case it is the Portfolio category, so all
    // galleries in that category are listed in the "re" variable.
    function delGallery() {
    if (!YD.hasClass(document.body, 'loggedIn')) {

    re = /\/(4958232_STy9F|4946254_R3Qcv|5144031_k2sVq|5144042_7gUQV|5144046_32NsP|5144110_myhEX)$/;

    home = YD.hasClass(document.body, 'homepage');
    re_empty = /\/(spacer.gif)$/;
    var oList = YD.getElementsByClassName('miniBox', 'div', this);
    for (i = 0; i < oList.length; i++) {
    if (((re.test(oList.getElementsByTagName('a')[0].href)) && (home)) || (re_empty.test(oList.getElementsByTagName('img')[0].src))) {
    oList.parentNode.removeChild(oList);
    }
    }
    }
    }
    YE.onContentReady('galleriesBox', delGallery);


    Still would like to know about doing it by listing categories instead of listing galleries.
  • jwalkerohjwalkeroh Registered Users Posts: 165 Major grins
    edited June 25, 2008
    Easier to read like this...
    // Delete certain galleries from the galleriesBox, meeting the following criteria:
    //   a) None when loggedIn.
    //   b) The galleries listed in the "re" variable, but only on the homepage.
    //   c) All empty galleries.
    // The specific intent here is to delete from the homepage galleriesBox, all of the
    // galleries for a certain category. In this case it is the Portfolio category, so all
    // galleries in that category are listed in the "re" variable.
    function delGallery() {
      if (!YD.hasClass(document.body, 'loggedIn')) {
    
        re = /\/(4958232_STy9F|4946254_R3Qcv|5144031_k2sVq|5144042_7gUQV|5144046_32NsP|5144110_myhEX)$/;
    
        home = YD.hasClass(document.body, 'homepage');
        re_empty = /\/(spacer.gif)$/;
        var oList = YD.getElementsByClassName('miniBox', 'div', this);
        for (i = 0; i < oList.length; i++) {
          if (((re.test(oList[i].getElementsByTagName('a')[0].href)) && (home)) || (re_empty.test(oList[i].getElementsByTagName('img')[0].src))) {
            oList[i].parentNode.removeChild(oList[i]);
          }
        }
      }
    }
    YE.onContentReady('galleriesBox', delGallery);
    
Sign In or Register to comment.