Blog Tags List

Jim Piller asked on April 13, 2017 22:33

I need to create a tag cloud using the API. My question is how do I get a distinct list of the tags that are stored in the database for all blog posts?

Correct Answer

Brenden Kehren answered on April 13, 2017 22:50

Did you look at the code for the TagCloud webpart at all? In there you can find what you're looking for. Essentially this is the API call that will return all tags for a tag group.

DataSet ds = TagInfoProvider.GetTags("TagGroupName", SiteContext.CurrentSiteID);  
DataView view = new DataView(ds.Tables[0]);
DataTable distinctValues = view.ToTable(true, "TagName");
0 votesVote for this answer Unmark Correct answer

Recent Answers


Jim Piller answered on April 17, 2017 23:28

Isn't that for the meta data page tags? I'm talking about the tags that you can add to a blog post. Are they the same thing?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 18, 2017 01:15

They are the same thing.

0 votesVote for this answer Mark as a Correct answer

Jim Piller answered on April 18, 2017 15:01

Ok, so if they are the same thing, do the blog posts have a default tag group set up, or do I have to define one and then assign it to each blog post in the site?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 18, 2017 15:15

Typically I define a tag group for blogs then you assign it to the main blog page and the group will then inherit through the blog month and blog post pages so you only have to set it once.

0 votesVote for this answer Mark as a Correct answer

Jim Piller answered on April 18, 2017 15:25

So, after your last message, I did some testing, and yes, it does appear that assigning the tag group to the blog would work. However, most of the posts already have tags, so if I go in and assign the tag group to posts that have tags already, the existing tags get wiped out. So I have to copy and paste the tags back in to the post in order to preserve them. But this does look like it solves my problem.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 18, 2017 15:30

Correct, when you change the tag group it will remove that relationship for that page and all inheriting pages. All of those tags will still be available in the database but assigned to that particular tag group you were using before.

If any one of the answers above helped, please mark it as the answer vs. just flagging the post as [Solved].

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.