Answers.Body: <p>Have you tried setting a variable and passing it down into your include?</p>
  
  <pre><code>{% set parentFolder = craft.request.getFirstSegment %}
  </code></pre>
  
  <p>Then pass <code>parentFolder</code> (or whatever you name it) down? This of course assumes your first segment is the name of your folder tree.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T15:21:27.857Z
Answers.Text: Hi Mark, I didn't test it, but I am pretty sure that it must work. Thanks for pointing me into the right direction... You just gotta love twig! thanks
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-11T15:40:50.027Z
Answers.Text: Happy to help! And yes TWIG rocks!!
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-04T23:22:08.653Z
Answers.LastActivityDate: 2014-11-04T23:22:08.653Z
Answers.UserDisplayName: Mark Busnelli Jr
Body: <p>For Structured entries, I always have about the same folder structure. 
  If I could access the parent's folder name, I woudn't have to change the <code>{% includes %}</code> when copying a folder. </p>
  
  <p>e.g.:</p>
  
  <p>blog<br>
  ---_common<br>
  ---_entry<br>
  ---_listing<br>
  ---index  </p>
  
  <p>so <code>_entry</code> looks like this: </p>
  
  <pre><code>{% extends "_layouts/_layout" %}
  
  {% block content %}
      {% include "blog/_common" %}
  {% endblock %}
  </code></pre>
  
  <p>and _listing looks like this: </p>
  
  <pre><code>{% set params = { section:'blog', limit: gl_config.cf_blog_limit} %}
  {% paginate craft.entries(params) as entries %}
  
      {% for entry in entries %}
          {% include "blog/_common" %}
      {% endfor %}
  
      {% include "_includes/_pagination" %}
  
  {% endpaginate %}
  </code></pre>
  
  <p>They look almost the same for every structure channel I use (e.g. discography, pressreleases, projects etc etc.) </p>
  
  <p>If I could use <code>{% include "PARENT_FOLDER_NAME/_common" %}</code></p>
  
  <p>I could just duplicate the folder and don't have to worry about these templates! </p>
  
  <p>btw: <code>the _common</code> template looks about like this: </p>
  
  <pre><code>&lt;article class="listing_item format"&gt;
  
      &lt;div class="listing_heading toggle_content"&gt;
          &lt;div class="listing_heading_date"&gt;
               &lt;span class="h1"&gt;{{ entry.postDate | date("d") }}&lt;/span&gt;
               {{ entry.postDate|date("F Y") }}
          &lt;/div&gt;
          &lt;div class="listing_heading_title"&gt;
              &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
  
              {% set tags = entry.cf_blog_tags %}
  
              {% if tags | length %}
                  {% for tag in tags %}
                      {{ tag.name }} 
                  {% endfor %}
              {% endif %}         
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="listing_content"&gt;
          {# 
              Content Matrix text / images / files / quotes / slideshows / videos etc..
          #}
          {% include "_includes/_content_blocks" %}
  
          &lt;p&gt;&lt;a href="{{ entry.url() }}"&gt;Permalink&lt;/a&gt;&lt;/p&gt;
  
          {# Edit #}
          {% include "_includes/_edit" %} 
      &lt;/div&gt;
  &lt;/article&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-04T22:59:44.497Z
Comments.Text: If the `_common` template is the same for all then can't you just place it in it own folder that is shared by all, and never have to change the parent folder? (or vice-versa depending on which is the static part).
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-12T14:01:25.977Z
Comments.Text: Please don't use meta-tags. Why did you add [feature-request]?
Comments.UserDisplayName: nicael
Tags: <templating>
Title: In a template: Is there a way to call the parent's folder name?
ThreadText: # In a template: Is there a way to call the parent's folder name?
  
  (Asked by: username_0 on 2014-11-04)
  
  For Structured entries, I always have about the same folder structure.
  If I could access the parent's folder name, I woudn't have to change the `{% includes %}` when copying a folder.
  
  e.g.:
  
  blog  
  ---\_common  
  ---\_entry  
  ---\_listing  
  ---index
  
  so `_entry` looks like this:
  
  ```
  {% extends "_layouts/_layout" %}
  
  {% block content %}
      {% include "blog/_common" %}
  {% endblock %}
  
  ```
  
  and \_listing looks like this:
  
  ```
  {% set params = { section:'blog', limit: gl_config.cf_blog_limit} %}
  {% paginate craft.entries(params) as entries %}
  
      {% for entry in entries %}
          {% include "blog/_common" %}
      {% endfor %}
  
      {% include "_includes/_pagination" %}
  
  {% endpaginate %}
  
  ```
  
  They look almost the same for every structure channel I use (e.g. discography, pressreleases, projects etc etc.)
  
  If I could use `{% include "PARENT_FOLDER_NAME/_common" %}`
  
  I could just duplicate the folder and don't have to worry about these templates!
  
  btw: `the _common` template looks about like this:
  
  ```
  <article class="listing_item format">
  
      <div class="listing_heading toggle_content">
          <div class="listing_heading_date">
               <span class="h1">{{ entry.postDate | date("d") }}</span>
               {{ entry.postDate|date("F Y") }}
          </div>
          <div class="listing_heading_title">
              <h1>{{ entry.title }}</h1>
  
              {% set tags = entry.cf_blog_tags %}
  
              {% if tags | length %}
                  {% for tag in tags %}
                      {{ tag.name }} 
                  {% endfor %}
              {% endif %}         
          </div>
      </div>
      <div class="listing_content">
          {# 
              Content Matrix text / images / files / quotes / slideshows / videos etc..
          #}
          {% include "_includes/_content_blocks" %}
  
          <p><a href="{{ entry.url() }}">Permalink</a></p>
  
          {# Edit #}
          {% include "_includes/_edit" %} 
      </div>
  </article>
  
  ```
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: If the `_common` template is the same for all then can't you just place it in it own folder that is shared by all, and never have to change the parent folder? (or vice-versa depending on which is the static part).  
  > **username_2**: Please don't use meta-tags. Why did you add [feature-request]?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2014-11-04. Score: 2 | Accepted answer
  
  Have you tried setting a variable and passing it down into your include?
  
  ```
  {% set parentFolder = craft.request.getFirstSegment %}
  
  ```
  
  Then pass `parentFolder` (or whatever you name it) down? This of course assumes your first segment is the name of your folder tree.
  
  > **Comments:**
  > **username_0**: Hi Mark, I didn't test it, but I am pretty sure that it must work. Thanks for pointing me into the right direction... You just gotta love twig! thanks  
  > **username_3**: Happy to help! And yes TWIG rocks!!  
  
  ---
  
  