Question

Provided a taxonomy name or ID, how do I iterate over a list of terms within the said taxonomy?

E.g. I want to do something like this:

var taxonomyId = 15;
foreach(dynamic item in get_terms(taxonomyId)) {
    @Display(item.text)
}
Was it helpful?

Solution

You need to inject ITaxonomyService in your controller/driver, and ITaxonomyService has a method which returns the list of terms for a taxonomyId.

IEnumerable<TermPart> GetTerms(int taxonomyId);

you can pass these terms to the view using model/viewmodel.

you can look into ITaxonomyService implementation in taxonomy module for further details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top