Display Category Items from a Sub Category Directory

Jacob Mallach asked on May 7, 2019 19:15

Hello,

I'm trying to populate a form dropdown box with a category sublist. I'm using a macro in the forms field tab to populate the dropdown <select> values.

Here is an example of my category directory structure.

Category
    item 1
    item 2
    Academics
        item A
        item B
    item 3
    item 4

This macro successfully returns all Category Names.

SiteObjects.Categories.ItemsAsFields.CategoryName#

However, I'm needing to ONLY return items located within a subcategory (Academics) list.

Category Directorty ---> SubCategory Directory (Academics) --> List all items (item A, item B)

This macro gets me closer, however it returns additional system text that is not needed, i.e., "CMS.Taxonomy.CategoryInfo (cms.category)"

SiteObjects.Categories.Academics.ReferringObjects.All#

What I'd like the macro to return are the values "itemA, itemB".

What am I doing wrong?

Thanks for the help.

Correct Answer

Dmitry Bastron answered on May 8, 2019 10:05

Hi Jacob,

You can use macro like this:

SiteObjects.Categories.Where("CategoryNamePath like '/Parent 1/%'").ItemsAsFields.CategoryName

Also, using Kentico Macro Console is super helpful:

Image Text

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.