More in this section

Forums / Developing with Sitefinity / Obtaining all tags for a specific blog

Obtaining all tags for a specific blog

2 posts, 0 answered
  1. Kevin
    Kevin avatar
    42 posts
    15 Mar 2005
    07 Apr 2009
    Link to this post
    I've been looking through the documentation but can't find how I can retrieve a list of all tags associated with a specific blog.  I can see the Generic Content method for this, but I'm not sure how this applies to the blog module (even though it's based on Generic Content), and whatever I try I get nothing back.  For example:

    m_contentManager =

    new ContentManager();
    m_BlogManager =
    new BlogManager();



    // Get blog
    IBlog blog = m_BlogManager.GetBlog(new Guid(this.BlogID));
    IList tags = m_contentManager.GetTags(blog.ID);


    In this case, 'tags' is always empty.  Obviously I'm just not understanding the relationship between the Blog (based on Generic Content) and the higher level Content Manager.  I'm assuming ContentManager.GetTags is only looking in GenericContent, but the BlogManager doesn't expose any similar method(s).

    What I am trying to do (in Sitefinity 3.6) is make a custom list of all available tags for a specific blog if that helps.

  2. Pepi
    Pepi avatar
    981 posts
    31 Jan 2017
    08 Apr 2009
    Link to this post

    GetTags(Guid contentId) method returns all tags used to tag a content item. This means that you can get the tags for the post, not for the blog (the blog is not IContent object). Here is a possible implementation of the required functionality:

            BlogManager m_BlogManager = new BlogManager(); 
            IList tags = new List<ITag>(); 
            // Get all posts for the blog 
            IList posts = m_BlogManager.GetPosts(string.Empty, new Guid[]{this.BlogID}); 
            foreach (IContent post in posts) 
                IList postTags = new List<ITag>(); 
                // Get the tags associated with the current post 
                postTags = m_BlogManager.Content.GetTags(post.ID); 
                foreach (ITag tag in postTags) 

    Hope this helps.

    All the best,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered