6

I'm looking to reorder my selected categories within a category field. I'm hoping this is possible because the order an editor selects these categories is important, primarily for the .first() category.

This functionality is currently possible using the entries fieldtype:

reorder entries

But not for the categories fieldtype:

reorder categories

Edit: The order is important here because this field determines where a given piece of content shows up on the site. Our main navigation is defined by these categories.

For instance, if a piece of content is tagged with "Lifelong Health" and "Health Conditions", but the content editor only wants it to show up on the "Lifelong Health" page.

We want an editor to be able to specify multiple categories however, because we have some robust related category action going on, and we have plans on adding in some personalization in a later phase. Having these robust relationships is vital.

In the interim, we've created a second field "Secondary Categories" that an editor can select, and limited the "Category" field to only one selection; but ultimately we'd like to be able to reorder the categories in one field.

  • You can't reorder the chosen categories. You can however, select them in the right order. Could you provide some more information on why the order is important, maybe there are better solutions to the bigger issue here. – Jan_dh Feb 8 '17 at 7:37
  • 1
    Hey @Jan_dh. When I remove all selected categories, and try to add them again, it looks like they always show up in the same order, no matter how I select them. This appears to be how they are laid out as a structure under the categories page in the CMS. cl.ly/051G173I0T2L I've gone ahead and updated my question as to why the order is important. – Rob Erskine Feb 8 '17 at 13:32
  • Can you not just use a structure instead of categories? And related entries rather than a category field.... – j00lz Jun 10 '17 at 9:18
  • Alternately you could also create a matrix field with a block holding a category field with max. 1 category. Then you can reorder each block as you wish. – kant312 Jun 10 '17 at 13:00
  • Thanks @Kant312 that last idea actually just might work. I think I can do that with minimal effort on readjusting my templates – Rob Erskine Jun 12 '17 at 13:06
1

Based on Brandon's answer here, this is currently not a feature of Craft CMS (as of v3.0.34).

If you need this functionality, I'd look into doing one of the following:

  • As mentioned in the comments and in Brandon's answer (linked above), create a matrix field with a block containing a category field that is limited to one category. This will allow you to add multiple categories but be able to rearrange the matrix blocks as needed (thereby changing the order of the categories).
  • Build your own plugin to achieve this functionality. Also check the current list of available plugins, as it's possible someone else has already created a plugin to achieve this.
  • Open an issue on the Craft CMS repo (based on Brandon's answer though, seems like P&T don't really think selected categories need to get reordered, so not sure how far you'll get with this unless P&T have changed their minds).

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.