Tag having a parameter as tagid in URL

Novice User asked on August 21, 2017 18:40

I am using following tranformation for displaying all tags a page is tagged with.

{% IfEmpty(DocumentTags,"","Tags: " + GetDocumentTags(DocumentTagGroupID, DocumentTags, "~/somepage")) #%}

This is currently creating a URL with a parameter of tagname. I would like to modify a parameter and changed it to have a tagid as parameter as my repetaer webpart takes a tagid as a parameter . How can i achieve this.

Correct Answer

Peter Mogilnitski answered on August 22, 2017 15:09

I think Tag Cloud web part has the functionality you are looking i.e it is uses tagid for URLs not the actual tags. It is in webparts/syndication/taggingcategories. Around lines 470 you will find

// Get the tags for documents

As Zachary said you can create custom macro and follow code from web part:

var ds = TagInfoProvider.GetTags(DocumentID); 
StringBuilder sb = new StringBuilder(count * 100);
int index = 0;
// Process the tags
foreach (DataRow dr in ds.Tables[0].Rows)
{
    if (index > 0)
    {
        sb.Append(TagSeparator + "\n");
    }
    // Create the link with query string parameter
    string paramUrl = URLHelper.AddParameterToUrl(url, "tagid",     ValidationHelper.GetString(dr["TagID"], ""));
    sb.Append("<span><a href=\"" + HTMLHelper.HTMLEncode(paramUrl) + "\" >" + HTMLHelper.HTMLEncode(dr["TagName"].ToString()) + "</a></span>");
              index++;
}
2 votesVote for this answer Unmark Correct answer

Recent Answers


Zachary Perry answered on August 21, 2017 20:09

I created a custom tranformation method to get the data. Just pass in the documentID to TagInfoProvider.GetTags(id)

Then just look thru those and generate your links.

2 votesVote for this answer Mark as a Correct answer

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