Hiding Predefined Categories

GoofyPhotographerGoofyPhotographer Registered Users Posts: 4 Beginner grinner
Hello,

I understand Smugmug doesn't provide a way to hide their predefined categories. Is there anything I can do at the API level to achieve this?

Thanks

Comments

  • David PLDavid PL Registered Users Posts: 80 Big grins
    edited May 15, 2010
    Hello,

    I understand Smugmug doesn't provide a way to hide their predefined categories. Is there anything I can do at the API level to achieve this?

    Thanks

    None of the API methods return any indication of which are predefined and which are not. However, you can filter these predefined categories out in your program simply by figuring out the CategoryIDs for the predefined categories. I was interested in this same thing, so I went through this and wrote a simple function like this:
    [FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] IsPredefinedCategory(int nCategoryID)
    {
        if ( (nCategoryID >= 0 && nCategoryID <= 63) || (nCategoryID == 67520) )
        {
            [COLOR=#0000ff][COLOR=#cdcdcd]        [/COLOR]return[/COLOR] true;
        }
     
        [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] false;
    }
    

    Of course if SM adds new predefined categories in the future, you will have to update your code. I don't think they have added any in a couple of years so it doesn't seem that will happen too often.
    [/SIZE][/FONT][/SIZE][/FONT]
  • GoofyPhotographerGoofyPhotographer Registered Users Posts: 4 Beginner grinner
    edited May 15, 2010
    David PL wrote: »
    None of the API methods return any indication of which are predefined and which are not. However, you can filter these predefined categories out in your program simply by figuring out the CategoryIDs for the predefined categories. I was interested in this same thing, so I went through this and wrote a simple function like this:
    [FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] IsPredefinedCategory(int nCategoryID)
    {
        if ( (nCategoryID >= 0 && nCategoryID <= 63) || (nCategoryID == 67520) )
        {
            [COLOR=#0000ff]return[/COLOR] true;
        }
     
        [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] false;
    }[/SIZE][/FONT][/SIZE][/FONT]
    


    Of course if SM adds new predefined categories in the future, you will have to update your code. I don't think they have added any in a couple of years so it doesn't seem that will happen too often.

    Thanks a lot, David. I figured any code would need revision from time-to-time, but since I'll have less than 10 categories, this will make life much easier.
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 15, 2010
    Hiding Predefined Categories
    David PL wrote:
    None of the API methods return any indication of which are predefined and which are not.

    Actually, they do now...API 1.2.2 returns a Type parameter.

    http://wiki.smugmug.net/display/API/show+1.2.2?method=smugmug.categories.get

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • David PLDavid PL Registered Users Posts: 80 Big grins
    edited May 15, 2010
    devbobo wrote: »
    Actually, they do now...API 1.2.2 returns a Type parameter.

    http://wiki.smugmug.net/display/API/show+1.2.2?method=smugmug.categories.get

    Cheers,

    David

    Very nice. I did not notice that change in that API method. It must be pretty recent because I've been using 1.2.2 for some time now and haven't run across that.

    Now looking back at the API functions for this, it looks like the smugmug.users.getTree still doesn't return the Type or the NiceName for each Category like smugmug.categories.get now does. That is the way I usually pull the categories for a user, and it would be very nice if those could be returned for that method as well.

    Thanks.
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 15, 2010
    Hiding Predefined Categories
    David PL wrote:
    Now looking back at the API functions for this, it looks like the smugmug.users.getTree still doesn't return the Type or the NiceName for each Category like smugmug.categories.get now does. That is the way I usually pull the categories for a user, and it would be very nice if those could be returned for that method as well.

    Passing NiceName,Type in Extras should return those parameters (from memory)
    David Parry
    SmugMug API Developer
    My Photos
  • blackgold9blackgold9 Registered Users Posts: 52 Big grins
    edited June 3, 2011
    devbobo wrote: »
    Passing NiceName,Type in Extras should return those parameters (from memory)

    Ive noticed when i request type in extras for getTree, i get back "SmugMug" for predefined categories, and nothing for user defined ones.
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited June 4, 2011
    blackgold9 wrote: »
    Ive noticed when i request type in extras for getTree, i get back "SmugMug" for predefined categories, and nothing for user defined ones.

    which API version ? and Type is only returned for Categories, since all SubCategories are user defined.
    David Parry
    SmugMug API Developer
    My Photos
Sign In or Register to comment.