Answers.Body: <p>A rather sneaky solution to your issue could be to create a matrix field that has one block type per category group. Each of those block types then could contain a single category field with the category source set to the corresponding category group. Limit those category fields to 1 category each and then limit the matrix field to one matrix block.</p>
  
  <p>This way your editors will be able to select only one of the matrix block types and that block type will limit the categories to the selected group.</p>
  
  <p>If you need this for some custom markup wizardry in your templates, make sure you understand <a href="http://twig.sensiolabs.org/doc/tags/set.html" rel="nofollow noreferrer">variable scoping in Twig loops</a> if you're trying to set some variable value while looping through your matrix data.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-10T08:28:29.913Z
Answers.LastActivityDate: 2016-11-10T08:28:29.913Z
Answers.UserDisplayName: Andris Sevcenko
Body: <p>I need only 2 main categories, A and B, and both can have unlimited subcategories. Ideal would be to split these into groups but how can an editor choose between groups AND only select or create a category?</p>
  
  <p>I could setup a checkbox field which asks is this A or B but this then needs to be linked to the category groups and might make the template tags to call the data unnecessary complicated.</p>
  
  <p>What's the craft-way todo this?</p>
  
Tags: <categories>
Title: Category structure with multiple groups
ThreadText: # Category structure with multiple groups
  
  (Asked by: username_0 on 2016-11-09)
  
  I need only 2 main categories, A and B, and both can have unlimited subcategories. Ideal would be to split these into groups but how can an editor choose between groups AND only select or create a category?
  
  I could setup a checkbox field which asks is this A or B but this then needs to be linked to the category groups and might make the template tags to call the data unnecessary complicated.
  
  What's the craft-way todo this?
  
  **Tags:** categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-10. Score: 2 | Accepted answer
  
  A rather sneaky solution to your issue could be to create a matrix field that has one block type per category group. Each of those block types then could contain a single category field with the category source set to the corresponding category group. Limit those category fields to 1 category each and then limit the matrix field to one matrix block.
  
  This way your editors will be able to select only one of the matrix block types and that block type will limit the categories to the selected group.
  
  If you need this for some custom markup wizardry in your templates, make sure you understand [variable scoping in Twig loops](http://twig.sensiolabs.org/doc/tags/set.html) if you're trying to set some variable value while looping through your matrix data.
  
  
  ---
  
  