List all categories via macro editor

Jacob Mallach asked on February 21, 2019 19:15

Hello,

Is there a system macro avail to display a list of all categories that have been assigned to a page type? I have a large number of files using an article page type (50 - 100) with various categories assigned to them. I'd like to see/print out a list of those category names currently attached to published page types.

Thanks!

Correct Answer

Brenden Kehren answered on February 21, 2019 20:54

Ok that's different than your original request. You can use something like this which will get you all the categories, flattened out, with no hierarchy.

{%SiteObjects.Categories.DisplayNames%}

2 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on February 21, 2019 19:42

Check out this similar question, should get you the answer or in the right direction.

0 votesVote for this answer Mark as a Correct answer

Jacob Mallach answered on February 21, 2019 20:48 (last edited on February 21, 2019 20:59)

Hi Brenden, I'd like to access a master list of All Categories used everywhere, not just for a current document. So, more like a master collection of those category values. Does that make sense? Trying to populate a webpart property with the values.

0 votesVote for this answer Mark as a Correct answer

Jacob Mallach answered on February 21, 2019 21:41 (last edited on February 21, 2019 21:41)

Thanks Brenden, This worked like a charm. Quick follow up question: Is there a (macro) way to sort the values in alphabetical order?

Cheers!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 21, 2019 21:57

Yup, try this:

{%SiteObjects.Categories.OrderBy("CategoryName").DisplayNames%}

Almost anything you can do in the Object query syntax, you can do in the Macro syntax.

2 votesVote for this answer Mark as a Correct answer

Jacob Mallach answered on February 21, 2019 23:30 (last edited on February 21, 2019 23:34)

Thanks Brendan,

That's good to know. The OrderBy is giving me some wonky results though. It's partly alphabetizing my items. Any clues as to what's happening here i.e, 'Forensic' is first and 'Business' is 19? (see output list below)

[0] Forensic Science (Forensic Science)

[1] Academics (Academics)

[2] Actuarial Science (Actuarial Science)

[3] Alumni (Alumni)

[4] Animal Behavior (Animal Behavior)

[5] Applied Physics (Applied Physics)

[6] Art (Art)

[7] Articles (Articles)

[8] Athletics (Athletics)

[9] Athletic Training (Athletic Training)

[10] Aviation Science (Aviation Science)

[11] Biochemistry (Biochemistry)

[12] Biology (Biology)

[13] Cross-Cultural Experience (Cross-Cultural Experience)

[14] Chemistry (Chemistry)

[15] Communication (Communication)

[16] Criminal Justice (Criminal Justice)

[17] Computer Science (Computer Science)

[18] Physical Therapy (Physical Therapy)

[19] Business (Business)

[20] Education (Education)

[21] Faculty and Staff (Faculty and Staff)

[22] Environmental Science (Environmental Science)

[23] English and Writing (English and Writing)

[24] Exercise Science (Exercise Science)

[25] F1RST Magazine (F1RST Magazine)

[26] F1RST Fall 2018 (F1RST Fall 2018)

[27] F1RST Summer 2018 (F1RST Summer 2018)

[28] F1RST Fall 2016 (F1RST Fall 2016)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 21, 2019 23:50

You could order it by how it appears in the content tree in the Categories application. You'd do something like this in your Order By statement:

CategoryLevel, CategoryOrder, CategoryName

Looks like it's ordering by the CategoryLevel and CategoryName only.

2 votesVote for this answer Mark as a Correct answer

Jacob Mallach answered on February 22, 2019 15:37 (last edited on February 22, 2019 16:35)

Hi Brendan,

Ok, we have some categories nested in sub directories that could possibly be causing the issue.

Does online documentation exist that lists the avail args for OrderBy() i.e., CatLevel, CatOrder, CatName, etc..?

Thanks for the help.

0 votesVote for this answer Mark as a Correct answer

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