Answers.Body: <p>I think you don't need or want the <code>{% nav %}</code> tag. This should work with your current nav:
  </p>
  
  <pre><code>{% set categories = craft.categories.group('products') %}
  
  &lt;ul id="sideNav"&gt;
    {% for category in categories %}
      {% set thisIsActiveCategory = (category.slug == craft.request.segment(2)) %}
      &lt;li{% if thisIsActiveCategory %} class="active"{% endif %}&gt;
        {{ category.title }}
        {% if thisIsActiveCategory %}
          {# loop over the subcategories #}
          {% set subCategories = craft.categories.descendantOf(category) %}
          &lt;ul&gt;
            {% for subCat in subCategories %}
              &lt;li&gt;{{subCat.title}}&lt;/li&gt;
            {% endfor %}
          &lt;/ul&gt;
        {% endif %}
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-03T23:44:17.360Z
Answers.Text: Marion, I'm going to try this on Monday. Looks a lot closer than what I have been working on. Thanks!
Answers.UserDisplayName: Steph
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-03T21:27:53.027Z
Answers.LastActivityDate: 2014-07-03T21:27:53.027Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>The outline of what you want to do looks reasonable. Here are some details:
  </p>
  
  <pre><code>{# get the category from the segment #}
  {% set parentCategory = craft.categories.slug(craft.request.segment(2)) %}
  
  {# get the children of this category #}
  {% set subCategories = craft.categories.descendantOf(parentCategory) %}
  
  {# loop over the subcategories #}
  {% for subCat in subCategories %}
    &lt;a href="{{subCat.url}}"&gt;{{subCat.title}}&lt;/a&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-03T19:05:23.127Z
Answers.Text: Thanks for your answer Marion. I'm trying to apply this to my current nav setup, which I'll edit into my original question. So far no success, but will keep trying.
Answers.UserDisplayName: Steph
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-03T18:25:34.877Z
Answers.LastActivityDate: 2014-07-03T18:25:34.877Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>I'm currently using Categories to organize an inventory of products. The hierarchy is straightforward: category, subcategory, and single product entry. The url structure I'm are hoping to use reflects the hierarchy: <em>homepage.com/products/category/subcategory/product</em></p>
  
  <p>So far, I've been able to <a href="https://craftcms.stackexchange.com/questions/353/how-do-i-add-a-subcategory-to-the-url-slug-for-a-channel-entry">display the proper slug for the products section</a> and <a href="https://craftcms.stackexchange.com/questions/4/how-do-you-list-categories-in-a-category-group">output a simple nav menu</a>. What I'd like to do now is refine the nav so that it only display the subcategories (children) of the category (parent) of product I'm on. I think I'm looking for <a href="https://craftcms.stackexchange.com/questions/590/how-do-you-only-show-children-of-active-parent-in-a-structure-sections-nav">something like this</a> but for Categories + Channel section rather than a Structure section.</p>
  
  <p>I have an idea of how to achieve this, but I'm having trouble getting it to work. I think what I'd like to do is pull the url segment, match it to a category, then display its children. I know I'm missing something basic or haven't fully grasped the syntax of Twig. Any help would be appreciated, thank you!</p>
  
  <p>-- edit --</p>
  
  <p>Marion's suggestion was right on:</p>
  
  <pre><code>{% set categories = craft.categories.group('products').level('1') %}
  
  &lt;ul id="sideNav"&gt;
    {% for category in categories %}
      {% set activeCat = (category.slug == craft.request.segment(2)) %}
      &lt;li{% if activeCat %} class="active"{% endif %}&gt;
        &lt;a href="{{category.url}}"&gt;{{ category.title }}&lt;/a&gt;
        {% if activeCat %}
          {% set subCategories = craft.categories.descendantOf(category) %}
          &lt;ul&gt;
            {% for subCat in subCategories %}
              &lt;li&gt;&lt;a href="{{subCat.url}}"&gt;{{subCat.title}}&lt;/a&gt;&lt;/li&gt;
            {% endfor %}
          &lt;/ul&gt;
         {% endif %}
     &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Tags: <categories>
Title: How do you only show children of “active” parent using categories?
ThreadText: # How do you only show children of “active” parent using categories?
  
  (Asked by: username_0 on 2014-07-03)
  
  I'm currently using Categories to organize an inventory of products. The hierarchy is straightforward: category, subcategory, and single product entry. The url structure I'm are hoping to use reflects the hierarchy: *homepage.com/products/category/subcategory/product*
  
  So far, I've been able to [display the proper slug for the products section](https://craftcms.stackexchange.com/questions/353/how-do-i-add-a-subcategory-to-the-url-slug-for-a-channel-entry) and [output a simple nav menu](https://craftcms.stackexchange.com/questions/4/how-do-you-list-categories-in-a-category-group). What I'd like to do now is refine the nav so that it only display the subcategories (children) of the category (parent) of product I'm on. I think I'm looking for [something like this](https://craftcms.stackexchange.com/questions/590/how-do-you-only-show-children-of-active-parent-in-a-structure-sections-nav) but for Categories + Channel section rather than a Structure section.
  
  I have an idea of how to achieve this, but I'm having trouble getting it to work. I think what I'd like to do is pull the url segment, match it to a category, then display its children. I know I'm missing something basic or haven't fully grasped the syntax of Twig. Any help would be appreciated, thank you!
  
  -- edit --
  
  username_1's suggestion was right on:
  
  ```
  {% set categories = craft.categories.group('products').level('1') %}
  
  <ul id="sideNav">
    {% for category in categories %}
      {% set activeCat = (category.slug == craft.request.segment(2)) %}
      <li{% if activeCat %} class="active"{% endif %}>
        <a href="{{category.url}}">{{ category.title }}</a>
        {% if activeCat %}
          {% set subCategories = craft.categories.descendantOf(category) %}
          <ul>
            {% for subCat in subCategories %}
              <li><a href="{{subCat.url}}">{{subCat.title}}</a></li>
            {% endfor %}
          </ul>
         {% endif %}
     </li>
    {% endfor %}
  </ul>
  
  ```
  
  **Tags:** categories
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-07-03. Score: 4 | Accepted answer
  
  I think you don't need or want the `{% nav %}` tag. This should work with your current nav:
  
  ```
  {% set categories = craft.categories.group('products') %}
  
  <ul id="sideNav">
    {% for category in categories %}
      {% set thisIsActiveCategory = (category.slug == craft.request.segment(2)) %}
      <li{% if thisIsActiveCategory %} class="active"{% endif %}>
        {{ category.title }}
        {% if thisIsActiveCategory %}
          {# loop over the subcategories #}
          {% set subCategories = craft.categories.descendantOf(category) %}
          <ul>
            {% for subCat in subCategories %}
              <li>{{subCat.title}}</li>
            {% endfor %}
          </ul>
        {% endif %}
      </li>
    {% endfor %}
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: username_1, I'm going to try this on Monday. Looks a lot closer than what I have been working on. Thanks!  
  
  ---
  
  ### Answer by username_1 on 2014-07-03. Score: 2
  
  The outline of what you want to do looks reasonable. Here are some details:
  
  ```
  {# get the category from the segment #}
  {% set parentCategory = craft.categories.slug(craft.request.segment(2)) %}
  
  {# get the children of this category #}
  {% set subCategories = craft.categories.descendantOf(parentCategory) %}
  
  {# loop over the subcategories #}
  {% for subCat in subCategories %}
    <a href="{{subCat.url}}">{{subCat.title}}</a>
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for your answer username_1. I'm trying to apply this to my current nav setup, which I'll edit into my original question. So far no success, but will keep trying.  
  
  ---
  
  