Umbraco.TagQuery 从当前页面获取标签
Umbraco.TagQuery get tags from current page
我想使用 TagQuery 显示 currentpages tags。我希望它像
一样简单
var tagList = Umbraco.TagQuery.GetAllContentTags(CurrentPage)
对此有什么简单的方法?
您应该能够使用以下方法获取您网页的标签:
var tagList = Umbraco.TagQuery.GetTagsForEntity(CurrentPage.Id);
标签应该只是当前页面上的 属性?例如
CurrentPage.tagsPropertyName.ToString().Split(',');
虽然我会使用强类型的东西,因为它比动态的东西更容易阅读并且更不容易出现奇怪的转换错误。
Model.Content.GetPropertyValue<string>("tagsPropertyName").Split(',');
你甚至可以写一个 属性 转换器来让它更整洁:http://www.theoutfield.co.uk/blog/2013/04/strongly-typed-property-values-using-property-editor-value-converters-in-umbraco
我想使用 TagQuery 显示 currentpages tags。我希望它像
一样简单var tagList = Umbraco.TagQuery.GetAllContentTags(CurrentPage)
对此有什么简单的方法?
您应该能够使用以下方法获取您网页的标签:
var tagList = Umbraco.TagQuery.GetTagsForEntity(CurrentPage.Id);
标签应该只是当前页面上的 属性?例如
CurrentPage.tagsPropertyName.ToString().Split(',');
虽然我会使用强类型的东西,因为它比动态的东西更容易阅读并且更不容易出现奇怪的转换错误。
Model.Content.GetPropertyValue<string>("tagsPropertyName").Split(',');
你甚至可以写一个 属性 转换器来让它更整洁:http://www.theoutfield.co.uk/blog/2013/04/strongly-typed-property-values-using-property-editor-value-converters-in-umbraco