Search code examples
tagsumbraco

Umbraco.TagQuery get tags from current page


I would like to display currentpages tags by using a TagQuery. I wish it was as easy as

var tagList = Umbraco.TagQuery.GetAllContentTags(CurrentPage)

What's an easy approach for this?


Solution

  • The tags should just be a property on CurrentPage? e.g.

    CurrentPage.tagsPropertyName.ToString().Split(',');
    

    I'd use the strongly typed stuff though, as that's a bit easier to read and less prone to weird casting errors than the dynamics stuff.

    Model.Content.GetPropertyValue<string>("tagsPropertyName").Split(',');
    

    You could even write a property converter to make it all a bit neater: http://www.theoutfield.co.uk/blog/2013/04/strongly-typed-property-values-using-property-editor-value-converters-in-umbraco