Creating Categories Programmatically
Managing categories in Publishing can be done multiple ways; from destination groups to bulk creation – but the most powerful way is with the Page Configuration Variable [category=*]
Like all other PCV we add this in the article content. Unlike other PCV, we can only utilise the variable when creating the campaign.
Examples & How to Use
Basic Example
Let's say we have 2 pieces of content that we want to categorise differently:
Usually we would have to create two destination groups to accomplish this, but now we can assign the category straight from the content.
Creating Nested Categories
Nested Categories can be created by adding a "/" between the titles. The category Dogs/Dog Toys will create the Dog Toys category below the Dogs category. We can leverage this when creating programmatic categories, too:
Combined with the Category/Post structure, we can create great URLs:
- pet-store.example.com/dogs/dog-food/dog-food-the-best-brands-this-year
- pet-store.example.com/dogs/dog-toys/dog-toys-ranked-our-picks
Combining with Variables & MPSS
We can also leverage any variables or MPSS too. We could abstract the "Dog" part of our articles to multiple pet types, for example:
...will create:
...and more combinations of course!