Retrieve Tags for Content in WCM

Is there an easy way to retrieve the tags associated with a piece of Content in WCM? I need to identify the tags from an item to determine whether to display a paticular panel

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

You can query UniformTag

If you have a reference to the current Content Record, you can simply use the Content object's Tags property to retrieve the list of tags.

Otherwise, you can query UniformTag (via the BOD APIs, as shown below):

using Asi.Business.ContentManagement;

UniformTagController uniformTagcontroller = UniformTagController.NewUniformTagController(Container);

DataRow[] rows = controller.SelectWithFilter(true, new BusinessFilter("UniformKey", Comparison.Equals, ContentKey);
if (!rows.IsNullOrEmpty())
{
    foreach (UniformTag uniformTag in rows)
    { // uniformTag.Tag contains the actual tag; you can compare its name, etc.

    }
}

Can you explain this

If you have a reference to the current Content Record, you can simply use the Content object's Tags property to retrieve the list of tags. I am attempting to check this in the public masterpage file.

From the master page, the

From the master page, the following code should work:

using Asi.Business.ContentManagement;
var page = Page as Asi.Web.UI.ContentRecordPage
if (page != null)
{
    Content content = Content.GetFromContentKey(page.ContentRecordKey, page.Container);
    foreach (Tag tag in content.Tags)
    {
        // Check tag.Name or tag.TagKey to see if it's the tag you're interested in.
    }
}
// if page is null, then the current page is not a WCM content record and has no tags.

Error in Method

The method GetFromContentKey does not exist in that context.

It should; it's a public

It should; it's a public static method.

Try fully qualifying it (Asi.Business.ContentManagement.Content.GetFromContentKey(...)).

Resolved Issue

 THank yo ufor all your advice I have figured it out, thanks to you. Below is the solution

protected

void CheckTags()var page = Page as Asi.Web.UI.ContentRecordPage;if (page != null)string t = page.ContentRecordKey.ToString();Content content = Asi.Business.ContentManagement.Content.GetFromContentKey(page.ContentRecordKey, page.Container);string tt = "";foreach (Asi.Business.ContentManagement.Tag tag in content.Tags)"<br />");

 

{

 

 

{

 

Asi.Business.ContentManagement.

 

 

 

{

tt = tag.Name.ToString();

Response.Write(tt +

}

}

}

There's also a report

In WCM look for the reports menu and there's a standard report that tells you which tags have been assigned to which content records.