BlogFunctions.GetDocumentTags() Not Working

Keith Donnell asked on July 29, 2015 16:16

The following code in my transformation is not displaying a list of tag links, as expected:

<%# Eval("DocumentTags") %>
<%# IfEmpty(Eval("DocumentTags"),"","Filed under: " + BlogFunctions.GetDocumentTags(Eval("DocumentTagGroupID"), Eval("DocumentTags"), "/Expert-Insights/Categories/Infrastructure/System-Center")) %>

The first Eval spits out "angry birds", cats, dogs, which is what I have set in the DocumentTags field for testing. DocumentTagGroupID is null/empty, and we do not need to limit to a specific set of tags.

So what am I doing wrong?

Also, are there any other helper methods I can use to simply get a list of the tags? I'm assuming based on the overloads of GetDocumentTags() that there is no way to control the markup that is returned.

Any help is greatly appreciated.

Correct Answer

Brenden Kehren answered on July 29, 2015 17:49

Your parent page needs to be assigned to a group. Tags belong to a group. So if you assign a tag group to your master page, then it will work fine. If you don't want to assign it to the whole site then just do the node you want the group to be assigned to. Fix is to simply add a group.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Keith Donnell answered on July 29, 2015 18:08 (last edited on July 29, 2015 18:09)

@Brenden - Thank you. Based on the documentation, tag groups come off as being optional. Adding the group and assigning it to the top-level blog node did the trick.

The second part of my question is still unanswered, however. As I expected, GetDocumentTags() generated a comma-separated list of links, however our design requires an unordered list, with no commas. How can I go about adjusting the markup?

0 votesVote for this answer Mark as a Correct answer

Keith Donnell answered on July 29, 2015 19:24 (last edited on December 10, 2019 02:30)

This may be considered a hack, but I was able to figure out how to customize the markup.

I had to create a query:

select top 10 T.TagName, T.TagGroupID from View_CONTENT_BlogPost_Joined V
INNER JOIN CMS_DocumentTag DT ON V.DocumentID = DT.DocumentID
INNER JOIN CMS_Tag T on DT.TagID = T.TagID
WHERE ##WHERE##

Then I created a "Repeater with custom query" web part and assigned the query, and set the where clause as:

V.DocumentID = {% CurrentDocument.DocumentID |(identity)GlobalAdministrator%}

and then created and set the transformation.

I hope this helps someone out in the future.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 29, 2015 22:09

Keith you could also use the Replace() method like so vs. another query and nested repeater. Just find the commas and replace them with html elements.

<ul> 
  <li>
    <%# BlogFunctions.GetDocumentTags(Eval("DocumentTagGroupID"), Eval("DocumentTags"), "/Expert-Insights/Categories/Infrastructure/System-Center").Replace(',', "</li><li>") %>
  </li>
</ul>
1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on January 30, 2016 13:05

Hi Brenden,

Thanks for this help, your answer helped me. Is there any way to add '#' at the begining of each DocumentTag?

e.g I should get #angry brids, #happy monkeys..

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

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