Skip to main content
deleted 11 characters in body; edited tags
Source Link
nicael
  • 2.4k
  • 7
  • 28
  • 48

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 %}{% includes %} when copying a folder.

so _entry_entry looks like this:

If I could use {% include "PARENT_FOLDER_NAME/_common" %}{% include "PARENT_FOLDER_NAME/_common" %}

Cheers
Stefan

btw: the _commonthe _common template looks about like this:

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.

so _entry looks like this:

If I could use {% include "PARENT_FOLDER_NAME/_common" %}

Cheers
Stefan

btw: the _common template looks about like this:

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.

so _entry looks like this:

If I could use {% include "PARENT_FOLDER_NAME/_common" %}

btw: the _common template looks about like this:

Source Link
outline4
  • 595
  • 3
  • 14

In a template: Is there a way to call the parent's folder name?

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!

Cheers
Stefan

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>