Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbraco - Get All tags used in a node/group

I have used GetTags() method under umbraco.cms.businesslogic.Tags.Tag to get all tags under a group or node.

var tags = umbraco.cms.businesslogic.Tags.Tag.GetTags("default");

But with umbraco.cms.businesslogic.Tags.Tag being obsolete now, is there any other better alternative?

Also, does the new library offer tag-based querying of nodes?

like image 303
Shaunak D Avatar asked Mar 30 '15 08:03

Shaunak D


1 Answers

Okay, So Umbraco 7 has the new TagService library to deal with tags.

To get all Tags used,

var service = UmbracoContext.Application.Services.TagService;
var blogTags = service.GetAllTags("default");

To get specific tag content GetTaggedContentByTag() is the method exposed,

var sports = service.TagService.GetTaggedContentByTag("Gaming");

It returns the TaggedEntity list and the TaggedEntity object with EntityId property.

Source Courtesy : Jimbo Jones

like image 126
Shaunak D Avatar answered Sep 26 '22 16:09

Shaunak D