This project is read-only.

How to return the selected Term of a Taxonomy attached to a Page?

Topics: Customizing Orchard, Troubleshooting, Writing modules, Writing themes
Feb 5, 2016 at 5:50 AM
Hi all, basically what the title says - via code - how do I go about discovering which term has been selected in a Page contentItem; note there could be two terms selected, the parent and one of its leaves? Thanks for your help in advance, cheers Orlando
Feb 5, 2016 at 2:13 PM
Looks like I over thought it, simply:

ContentItem page = ...
var selectedTerms = page.As<TermsPart>().Terms;
var siteTermId = selectedTerms.First().TermRecord.Id;//parent
var pageTermId = selectedTerms[1].TermRecord.Id;//child

Thanks guys.