Answers.Body: <p>In addition to using the url segments as megatrond suggested. You can also define 'Entry Types', and use <code>if..then</code> conditionals or <a href="http://buildwithcraft.com/docs/templating/switch" rel="nofollow">switch</a> statements in your template to modify the layout or include different sub-templates, as required.</p>
  
  <pre><code>{% if entry.type == 'project' %}
      {% include '/projects/_tabbed-entry' %}
  {% endif %}
  </code></pre>
  
  <p>Furthermore you can use <code>levels</code> and other heirarchy tools (<code>descendants</code>, <code>ancestors</code>, <code>parent</code>, etc)  to dynamically <a href="http://buildwithcraft.com/help/structure-nav" rel="nofollow">construct navigation</a> and/or tabs, such that, for example, the top 2 or 3 levels can be used for your primary navigation, and subsequent levels can be used to construct tabs or sub-nav on the page.</p>
  
  <pre><code>{# build primary nav #}
  {% set navEntries = craft.entries.section('pages').level('&lt;= 2') %}
  &lt;ul class="nav__level1"&gt;
      {% nav entry in navEntries %}
          &lt;li&gt;
              &lt;a href="{{ entry.url }}"&gt;&lt;span&gt;{{ entry.title }}&lt;/span&gt;&lt;/a&gt;
              {% ifchildren %}
                  &lt;ul class="nav__level{{ entry.level + 1 }}"&gt;
                      {% children %}
                  &lt;/ul&gt;
              {% endifchildren %}
          &lt;/li&gt;
      {% endnav %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>And for tabs (which works equally well for subnav):</p>
  
  <pre><code>{# build tabs #}
  {% set tabEntries = entry.parent.descendants(1) %}
  &lt;ul class="tabs"&gt;
      {% for tabEntry in tabEntries %}
          &lt;li class="tab" &gt;
              &lt;a href="{{ tabEntry.url }}" {% if tabEntry.id == entry.id %}class="selected"{% endif %} &gt;{{ tabEntry.title }}&lt;/a&gt;
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  
  &lt;div class="page-content"&gt;
      {{ entry.body }}
  &lt;/div&gt;
  </code></pre>
  
  <p>The examples above will link to each sub-page/tab as a unique url. However, if you want to load the tab content via ajax then you can specify which part of the template is returned in the ajax request, using <code>craft.request.isAjax</code>. This would allow you to essentially load the template into itself if you wanted:</p>
  
  <pre><code>{% if craft.request.isAjax %}
      {# return only the content #}
  {% else %}
      {# return the full page with header, nav, content, etc. #}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T15:34:53.340Z
Answers.LastActivityDate: 2014-11-11T16:47:32.753Z
Answers.LastEditDate: 2014-11-11T16:47:32.753Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <p>Disclaimer: I haven't ever used structure, but hopefully the method described below also works for that section type.</p>
  
  <p>You can do this quite easily with URL-segments</p>
  
  <p>Consider a URL like so:</p>
  
  <pre><code>http://www.domain.com/section/entry/
  
  http://www.domain.com/section/entry/subview-1
  </code></pre>
  
  <p>And so on.</p>
  
  <p>The section/entry route will hit your entry template, but you can create a new route</p>
  
  <pre><code>section/{slug}/*
  </code></pre>
  
  <p>And point it to your subview template.</p>
  
  <p>There, you ask craft for whatever is in URL segment 3 like so:</p>
  
  <pre><code>craft.request.getSegment(3)
  </code></pre>
  
  <p>And display content based on that.</p>
  
  <p>To get the entry you are on currently, just filter on segment 2 like so:</p>
  
  <pre><code>{% for entry in craft.entries.section('section').slug(craft.request.getSegment(2)) %}
      {{ entry }}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T14:03:25.817Z
Answers.Text: This looks great, thanks. Related to your last code snippet, I reference entry in my outer _layout template to access global data related to an entry. Is there any way to make sure the outer layout uses the entry matched on from the slug?
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T14:42:26.270Z
Answers.Text: I've solved this by defining these instances in a block and overriding the block in the included templates. Thanks again.
Answers.UserDisplayName: Alex H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T12:30:57.480Z
Answers.LastActivityDate: 2014-11-11T12:30:57.480Z
Answers.UserDisplayName: megatrond
Body: <p>I have a one-level structure where I am storing a client's projects, with the ability to reorder them by dragging the entries in the structure.</p>
  
  <p>Each project has been designed to have multiple subpages of information available, accessible by clicking on tabs, where each tabbed view shows a subset of the project data.</p>
  
  <p>Ideally, each tab would have its own URL so I can deep-link to the subpages, each served by a different template, but load in the views via ajax when a tab is clicked on. Is it possible to derive multiple child views with distinct templates from a single entry, without having to manually add child tab entries for every project, which I definitely don't want to make the client do?</p>
  
  <p>The alternative would be to load in all the tabs on initial page load, and show and hide them as they're clicked on, and use pushstate to deep link to those tabs, but I'd rather have them as proper server side URLs, I think.</p>
  
  <p>Does anyone know if this is possible?</p>
  
Tags: <structure><ajax><children>
Title: Is there a way to divide an entry's data into multiple subviews with unique URLs?
ThreadText: # Is there a way to divide an entry's data into multiple subviews with unique URLs?
  
  (Asked by: username_0 on 2014-11-11)
  
  I have a one-level structure where I am storing a client's projects, with the ability to reorder them by dragging the entries in the structure.
  
  Each project has been designed to have multiple subpages of information available, accessible by clicking on tabs, where each tabbed view shows a subset of the project data.
  
  Ideally, each tab would have its own URL so I can deep-link to the subpages, each served by a different template, but load in the views via ajax when a tab is clicked on. Is it possible to derive multiple child views with distinct templates from a single entry, without having to manually add child tab entries for every project, which I definitely don't want to make the client do?
  
  The alternative would be to load in all the tabs on initial page load, and show and hide them as they're clicked on, and use pushstate to deep link to those tabs, but I'd rather have them as proper server side URLs, I think.
  
  Does anyone know if this is possible?
  
  **Tags:** structure, ajax, children
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-11-11. Score: 4 | Accepted answer
  
  Disclaimer: I haven't ever used structure, but hopefully the method described below also works for that section type.
  
  You can do this quite easily with URL-segments
  
  Consider a URL like so:
  
  ```
  http://www.domain.com/section/entry/
  
  http://www.domain.com/section/entry/subview-1
  
  ```
  
  And so on.
  
  The section/entry route will hit your entry template, but you can create a new route
  
  ```
  section/{slug}/*
  
  ```
  
  And point it to your subview template.
  
  There, you ask craft for whatever is in URL segment 3 like so:
  
  ```
  craft.request.getSegment(3)
  
  ```
  
  And display content based on that.
  
  To get the entry you are on currently, just filter on segment 2 like so:
  
  ```
  {% for entry in craft.entries.section('section').slug(craft.request.getSegment(2)) %}
      {{ entry }}
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: This looks great, thanks. Related to your last code snippet, I reference entry in my outer _layout template to access global data related to an entry. Is there any way to make sure the outer layout uses the entry matched on from the slug?  
  > **username_0**: I've solved this by defining these instances in a block and overriding the block in the included templates. Thanks again.  
  
  ---
  
  ### Answer by username_1 on 2014-11-11. Score: 2
  
  In addition to using the url segments as username_2 suggested. You can also define 'Entry Types', and use `if..then` conditionals or [switch](http://buildwithcraft.com/docs/templating/switch) statements in your template to modify the layout or include different sub-templates, as required.
  
  ```
  {% if entry.type == 'project' %}
      {% include '/projects/_tabbed-entry' %}
  {% endif %}
  
  ```
  
  Furthermore you can use `levels` and other heirarchy tools (`descendants`, `ancestors`, `parent`, etc) to dynamically [construct navigation](http://buildwithcraft.com/help/structure-nav) and/or tabs, such that, for example, the top 2 or 3 levels can be used for your primary navigation, and subsequent levels can be used to construct tabs or sub-nav on the page.
  
  ```
  {# build primary nav #}
  {% set navEntries = craft.entries.section('pages').level('<= 2') %}
  <ul class="nav__level1">
      {% nav entry in navEntries %}
          <li>
              <a href="{{ entry.url }}"><span>{{ entry.title }}</span></a>
              {% ifchildren %}
                  <ul class="nav__level{{ entry.level + 1 }}">
                      {% children %}
                  </ul>
              {% endifchildren %}
          </li>
      {% endnav %}
  </ul>
  
  ```
  
  And for tabs (which works equally well for subnav):
  
  ```
  {# build tabs #}
  {% set tabEntries = entry.parent.descendants(1) %}
  <ul class="tabs">
      {% for tabEntry in tabEntries %}
          <li class="tab" >
              <a href="{{ tabEntry.url }}" {% if tabEntry.id == entry.id %}class="selected"{% endif %} >{{ tabEntry.title }}</a>
          </li>
      {% endfor %}
  </ul>
  
  <div class="page-content">
      {{ entry.body }}
  </div>
  
  ```
  
  The examples above will link to each sub-page/tab as a unique url. However, if you want to load the tab content via ajax then you can specify which part of the template is returned in the ajax request, using `craft.request.isAjax`. This would allow you to essentially load the template into itself if you wanted:
  
  ```
  {% if craft.request.isAjax %}
      {# return only the content #}
  {% else %}
      {# return the full page with header, nav, content, etc. #}
  {% endif %}
  
  ```
  
  
  ---
  
  