Answers.Body: <p>Probably the simplest way is to split the code up like this in your template.</p>
  
  <pre><code>{% switch entry.level %}
      {% case 1 %}        
          {# all the food #}
      {% case 2 %}
          {# course level #}
      {% case 3 %}
          {# one dish #}
  {% endswitch %}
  </code></pre>
  
  <p>This give you a lot of fine control over each level of your structure.</p>
  
  <p>Or even simpler:</p>
  
  <pre><code>{% set entries = craft.entries.section('food').descendantOf( entry ) %}
  </code></pre>
  
  <p>and run the same loop regardless of which level you are on.</p>
  
  <p>You can also have a look at <a href="http://buildwithcraft.com/help/structure-nav" rel="nofollow">this page</a> to see how to create a navigation for a structured section.</p>
  
  <p>And if you want elaborately styled menus check out <a href="http://craftcookbook.net/recipes/388" rel="nofollow">this link</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-15T13:27:29.847Z
Answers.Text: This makes perfect sense. But I think I'm still in the same spot. I've edited my question using your solution to show what I mean.
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-15T04:58:13.553Z
Answers.LastActivityDate: 2015-08-15T05:14:54.977Z
Answers.LastEditDate: 2015-08-15T05:14:54.977Z
Answers.UserDisplayName: j00lz
Body: <p>For simplicity, I'm building a site for a restaurant. The "Menu" page has the following url(s):</p>
  
  <pre><code>mysite.com/food/appetizers
  mysite.com/food/sandwiches
  </code></pre>
  
  <p><code>food</code> is a structure. It contains every entree the restaurant has. I've nested the actual entree to under the corresponding category. For example:</p>
  
  <pre><code>mysite.com/food/appetizers
                           /cheese-curds
                           /french-fries 
  
  mysite.com/food/sandwiches
                          /whole-sandwich
                          /half-sandwich
  </code></pre>
  
  <p>..and so on.</p>
  
  <p>On <code>mysite.com/food/</code> I can render all entrees under thier corresponding category like this:</p>
  
  <pre><code>{% set entries = craft.entries.section('food') %}
  
   {% for entry in entries %}
         {% if entry.type == 'category' %}  
             &lt;h3&gt;&lt;a href="{{ entry.getUrl }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h3&gt;
         {% endif %}
  
         {% set children = entry.getChildren() %}
         {% for child in children %}
             &lt;h5&gt;&lt;a href="{{ child.getUrl }}"&gt;{{ child.title }}&lt;/a&gt;&lt;/h5&gt;
         {% endfor %}
   {% endfor %}
  </code></pre>
  
  <p>Everything is working great. All entrees are listed below their corresponding "category" on my <code>/food/</code> page. I can click on each individual entree "cheese-curds" for example, and can get the entry details.</p>
  
  <p>For templates I have <code>_entry</code> and <code>index</code>. </p>
  
  <p><code>index</code> is used on <code>mysite.com/food</code> <code>_entry</code> is used on each entree. </p>
  
  <p>Where I'm stuck is how to render the entries for the current category. For example:</p>
  
  <pre><code>mysite.com/food/appetizers
  </code></pre>
  
  <p>I'm not sure How to get past my initial command of getting ALL entires:</p>
  
  <pre><code> {% set entries = craft.entries.section('food') %}
  
   {% for entry in entries %}
         {% if entry.type == 'category' %}
         ....
         .... 
  </code></pre>
  
  <p>To only this:</p>
  
  <pre><code>{% if entry.type == 'category' %}
    ....
    ....
  </code></pre>
  
  <p>So that I am only listing out the entries for the current category. It's OK if I need to create a new template, I'm not sure how to tell Craft how to do that. Or is there a better approach to getting all entries for the structure? It seems simple enough in theory, I keep talking myself in circles.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thank you @j00lz
  Your solution makes perfect sense. I think I either don't <em>quite</em> understand, or I'm still at the same spot I was before.</p>
  
  <pre><code>{% switch entry.level %}
      {% case 1 %}        
          {# this is mysite.com/food #}
          {# outputs #}
          Appetizers
              Cheese Curds
              French Fries
          Sandwiches
              Sandwich One
              Sandwich Two
      {% case 2 %}
          {# this is mysite.com/food/appetizers
          {# outputs #}
          Appetizers
              Cheese Curds
              French Fries
      {% case 3 %}
          {# this is mysite.com/food/appetizers/french-fries
          {# outputs #}
              French Fries
              French fries are awesome!
  {% endswitch %}
  </code></pre>
  
  <p>So, it's like I need another template to only show the 2nd case on the page.
  I can list all foods, and the actual entrée (3rd case) using 2 templates. I'm hung up on that middle page where it would only list the title of the entrée, and then the children entrée.</p>
  
  <p>I thought about putting an <code>if</code> statement at the top of the page that checks the URL level. If it's only <code>/food/</code> do "x", if its <code>/food/appetizers</code> do "y", but that seems to assume an awful lot. </p>
  
  <p>Maybe there is a better route to go all together. I only had a structure in mind because of the nested elements that I wanted to be able to control where they were.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-16T02:38:56.017Z
Comments.Text: the switch is doing exactly that, checking which level of entry you are on and outputting a 'template' to match. You need to change what's in those individual cases to suit your markup needs.
Comments.UserDisplayName: j00lz
Tags: <structure><children>
Title: How do I render specific child entries of a structure based on url segment
ThreadText: # How do I render specific child entries of a structure based on url segment
  
  (Asked by: username_0 on 2015-08-15)
  
  For simplicity, I'm building a site for a restaurant. The "Menu" page has the following url(s):
  
  ```
  mysite.com/food/appetizers
  mysite.com/food/sandwiches
  
  ```
  
  `food` is a structure. It contains every entree the restaurant has. I've nested the actual entree to under the corresponding category. For example:
  
  ```
  mysite.com/food/appetizers
                           /cheese-curds
                           /french-fries 
  
  mysite.com/food/sandwiches
                          /whole-sandwich
                          /half-sandwich
  
  ```
  
  ..and so on.
  
  On `mysite.com/food/` I can render all entrees under thier corresponding category like this:
  
  ```
  {% set entries = craft.entries.section('food') %}
  
   {% for entry in entries %}
         {% if entry.type == 'category' %}  
             <h3><a href="{{ entry.getUrl }}">{{ entry.title }}</a></h3>
         {% endif %}
  
         {% set children = entry.getChildren() %}
         {% for child in children %}
             <h5><a href="{{ child.getUrl }}">{{ child.title }}</a></h5>
         {% endfor %}
   {% endfor %}
  
  ```
  
  Everything is working great. All entrees are listed below their corresponding "category" on my `/food/` page. I can click on each individual entree "cheese-curds" for example, and can get the entry details.
  
  For templates I have `_entry` and `index`.
  
  `index` is used on `mysite.com/food` `_entry` is used on each entree.
  
  Where I'm stuck is how to render the entries for the current category. For example:
  
  ```
  mysite.com/food/appetizers
  
  ```
  
  I'm not sure How to get past my initial command of getting ALL entires:
  
  ```
   {% set entries = craft.entries.section('food') %}
  
   {% for entry in entries %}
         {% if entry.type == 'category' %}
         ....
         .... 
  
  ```
  
  To only this:
  
  ```
  {% if entry.type == 'category' %}
    ....
    ....
  
  ```
  
  So that I am only listing out the entries for the current category. It's OK if I need to create a new template, I'm not sure how to tell Craft how to do that. Or is there a better approach to getting all entries for the structure? It seems simple enough in theory, I keep talking myself in circles.
  
  **EDIT**
  
  Thank you @username_1
  Your solution makes perfect sense. I think I either don't *quite* understand, or I'm still at the same spot I was before.
  
  ```
  {% switch entry.level %}
      {% case 1 %}        
          {# this is mysite.com/food #}
          {# outputs #}
          Appetizers
              Cheese Curds
              French Fries
          Sandwiches
              Sandwich One
              Sandwich Two
      {% case 2 %}
          {# this is mysite.com/food/appetizers
          {# outputs #}
          Appetizers
              Cheese Curds
              French Fries
      {% case 3 %}
          {# this is mysite.com/food/appetizers/french-fries
          {# outputs #}
              French Fries
              French fries are awesome!
  {% endswitch %}
  
  ```
  
  So, it's like I need another template to only show the 2nd case on the page.
  I can list all foods, and the actual entrée (3rd case) using 2 templates. I'm hung up on that middle page where it would only list the title of the entrée, and then the children entrée.
  
  I thought about putting an `if` statement at the top of the page that checks the URL level. If it's only `/food/` do "x", if its `/food/appetizers` do "y", but that seems to assume an awful lot.
  
  Maybe there is a better route to go all together. I only had a structure in mind because of the nested elements that I wanted to be able to control where they were.
  
  **Tags:** structure, children
  
  > **Comments:**
  > **username_1**: the switch is doing exactly that, checking which level of entry you are on and outputting a 'template' to match. You need to change what's in those individual cases to suit your markup needs.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-15. Score: 1
  
  Probably the simplest way is to split the code up like this in your template.
  
  ```
  {% switch entry.level %}
      {% case 1 %}        
          {# all the food #}
      {% case 2 %}
          {# course level #}
      {% case 3 %}
          {# one dish #}
  {% endswitch %}
  
  ```
  
  This give you a lot of fine control over each level of your structure.
  
  Or even simpler:
  
  ```
  {% set entries = craft.entries.section('food').descendantOf( entry ) %}
  
  ```
  
  and run the same loop regardless of which level you are on.
  
  You can also have a look at [this page](http://buildwithcraft.com/help/structure-nav) to see how to create a navigation for a structured section.
  
  And if you want elaborately styled menus check out [this link](http://craftcookbook.net/recipes/388)
  
  > **Comments:**
  > **username_0**: This makes perfect sense. But I think I'm still in the same spot. I've edited my question using your solution to show what I mean.  
  
  ---
  
  