1

I'm porting a site to DXA. We use categories/keywords to populate dropdowns. Previously this was done in the Content Manager templating. In DXA that should happen application-side so I've published the categories. What I want to do is enumerate the keywords in a category.

So far, the only documentation I've found relates to DXA's navigation support. That isn't what I need, as I just want direct access to the category/keyword data.

Does the framework have anything that approximates to a CategoryModel? Actually, I care very little about the category itself, and would be content with a List<KeywordModel>. Is there a DXA-supported way to tackle this, or must I resort to the CIL? We're using DXA2.2 with Tridion 8.5.

2

DXA indeed offers out-of-the box support for Navigation based on Taxonomies and has a KeywordModel for mapping a Keyword field to a View Model.

For all other Taxonomy-related functionality, you should indeed use the applicable CD APIs. That is: CIL for 8.x or PCA for 9.x.

2

For your Drop down list component

  • Schema: add "ddlist" a multi-value text field based on the drop down list category
  • Component: select all the keywords you want for your dropdown list in the component multivalue text field "ddlist" in the order you want them in the drop down
  • Publish
  • update your model to add <List>KeywordModel ddlist
  • access the list in your view

For each keyword you can access the keyword Title, Description, Value and Metadata to construct your dropdown list in the view. Translatable Keywords are very useful for multi language sites :-)

1
  • That's a good answer, Chris. I have already built a working implementation with a taxonomy query via the CIL, but I will consider this pattern for future use. – Dominic Cronin Sep 21 '20 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.