Pergunta

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

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top