ITagQuery
Working with tags in Umbraco
How to reference ITagQuery
@inject ITagQuery _tagQuery;using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.PublishedCache;
namespace UmbracoHelperDocs.Controllers;
[ApiController]
[Route("/umbraco/api/tags")]
public class TagApiController : Controller
{
private readonly ITagQuery _tagQuery;
public TagApiController(ITagQuery tagQuery)
{
_tagQuery = tagQuery;
}
[HttpGet("getmediatags")]
public ActionResult<IEnumerable<string>> GetMediaTags()
{
return _tagQuery.GetAllMediaTags().Select(tag => tag.Text).ToList();
}
}Examples
GetAllContentTags([string tagGroup])
GetAllMediaTags([string tagGroup])
GetAllMemberTags([string tagGroup])
GetAllTags([string tagGroup])
GetContentByTag(string tag, [string tagGroup])
GetContentByTagGroup(string tagGroup)
GetMediaByTag(string tag, [string tagGroup])
GetMediaByTagGroup(string tag, [string tagGroup])
GetTagsForEntity(int contentId, [string tagGroup])
GetTagsForProperty(int contentId, string propertyTypeAlias, [string tagGroup])
Last updated
Was this helpful?