All things Tags and Tag Groups

David Pearson asked on February 25, 2015 21:28

In Kentico there is Tag Groups and Tags… I am guessing the Tag Group is a way of grouping tags.
The API example shows how to create the Tag Group and Add a Tag to a Document. The example for adding a tag to a Document shows. Root.DocumentTags = “”\ My new Tag\”” Am I correct in assuming this only assigns the tag to the Root.DocumentTags and does not create a record in the CMS_Tag table or CMS_DoucmentTag?

I did find TagInfoProvider.SetTagInfo(TagInfo) for adding tags.
Does Root.DocumentTags = “”\ My new Tag\”” take care of the CMS_DocumentTag entry?

Thanks David

Correct Answer

Martin Danko answered on March 2, 2015 03:57

Hello David,

When you click on the magnifying glass icon, you can see the sample code but when you click on the button, it will execute the code, did you know about it?

So the first thing is: when you are trying to Add tag to page, the tag group must exist. In this case the API example for "Adding tag to page", will add tag to CMS_Document -> column DocumentsTag which will automatically create a record for this tag in CMS_Tag table and store relationship between ID of page and ID of document in the CMS_DocumentTag table.

By design of application, every tag that is added to any document/page is automatically created in the CMS_Tag table and their relationship is stored in the CMS_DocumentTag table.

But I believe that in this case it would be even easier and faster to try to execute the code and check all the changes in the database, so you don't need just to guess :)

Regards, Martin

0 votesVote for this answer Unmark Correct answer

Recent Answers


David Pearson answered on March 4, 2015 17:18

Yes I did see the magnifying glass icon, I did find the example code under CMSAPIExamples.
I place some debug points in the example code and did some queries of CMS_Tag and CMS_TagGroup. I did find TreeNode root.Update will take care of the adding “My New Tag” to CMS_Tag also found my other answer to the other question, it does the Tag Count and updates the TagCount value for you.

Summary: you can use TreeNode root.Update to add new tags without using the TagInfoProvidor. The TreeNode class will take care of everything…. You can use the Tag Group as a way of grouping your tags…

0 votesVote for this answer Mark as a Correct answer

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