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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With