+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Get a list of tags for a specific library

Get a list of tags for a specific library

6 posts, 1 answered
  1. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    30 Dec 2010
    Link to this post
    Hi,

    I am needing to get a list of all the tags associated with a specific library.
    I can get a list of all the tags by provider:

    ContentManager cm = new ContentManager(ProviderName);
    IList Tags = cm.GetTags();

    which works for any generic content type, including libraries.
    I need to pull a list of tags for one specific library.  How would I do that?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Dec 2010
    Link to this post
    Hi Keith,

    Tags are created per provider and you cannot have tags for a single library. Tags are associated with a content items - IContent object and not with the ILibrary object. You can get all tags for a given item by using GetTags(Guid contentId) - Get all Tags for a specific content item by passing its ID

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    30 Dec 2010
    Link to this post
    So there is no way to filter these tags by library? I ask because in the Library module, if I click on (library name) then click "Tags" in the left hand pane, it shows me a list of all tags with the number of content items in (library name) with that tag.  I want to do something similar to that.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Dec 2010
    Link to this post
    Hello Keith,

    You can get the content item and its Parent with is the library. The ITag is associated with the content item in the library.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    30 Dec 2010
    Link to this post
    K....
    I am not looking for a list of tags for a single content item.  I am looking for a list of tags for all content items in a specific library.

    [LibraryProvider]--|
                                 |--library1
                                 |--library2
                                 |--library3----|--gcontentItem1-----tag_x---tag_y---tag_z
                                                      |--gcontentItem2-----tag_x
                                                      |--gcontentItem3-----tag_x---tag_y
                                                      |--gcontentItem4-----tag_x---tag_z
                                                                                     [_________________]--I want these tags

    If I need to get every content item from the specific library and just count all the tags I guess I could do that, I was just hoping there was an easier and cleaner way to do this.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Dec 2010
    Link to this post
    Hello Keith,

    Unfortunately there is not API methods that you can use to get all tags for all item in a particular library. You have to get all items from this library and then get the tags for the items.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
Register for webinar
6 posts, 1 answered