Pregunta

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)
}
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top