2

I realise this is probably a duplicate of the other questions just like it but I thought I'd raise it here before filing a bug with P&T.

Basically, when a new entry is added to a section, the template cache isn't invalidating. Here is the template in question, is there anything in the code that would cause this?

    {% extends "_layouts/two-col" %}

    {% block main %}

        {% cache unless not craft.config.cache %}

        {{entry.body}} 

        {% set cutoffDate = now|date_modify('- ' ~ '1' ~ ' days') %}
        {% set events = craft.entries.section('whatsOn').order('dateStart') %}

        {% set eventIds = [] %}
        {% for event in events if (event.dateEnd ? event.dateEnd : event.dateStart) >= cutoffDate %}
          {% set eventIds = eventIds|merge([event.id]) %}
        {% endfor %}

        {% set allEvents = craft.entries.id(eventIds).fixedOrder('true') %}

        {% paginate allEvents.limit(12) as events %}

        <ul class="list list--articles">

            {% for event in events %}

                <li class="item" itemscope itemtype="http://schema.org/Event">

                    <header class="item__header">

                        <div class="item__meta">

                            <time itemprop="startDate" content="{{event.dateStart}}" datetime="{{event.dateStart}}">{{event.dateStart|date("jS F Y")}}</time>

                            {% if event.dateEnd|length %}
                                — <time itemprop="endDate" content="{{event.dateStart}}" datetime="{{event.dateStart}}">{{event.dateEnd|date("jS F Y")}}</time>
                            {% endif %}

                        </div>

                        <h3 class="item__title h4" itemprop="name"><a href="{{ event.url }}" class="">{{ event.title }}</a></h3>

                        <div class="item__type">
                            <span class="tag tag--{{event.eventType|slugify}}">{{event.eventType}}</span>
                            <span itemprop="location" itemscope itemtype="http://schema.org/Place"> {{event.location}}</span>
                        </div>

                    </header>

                    <div class="item__description">
                        <a href="{{ event.url }}">Find out more</a>
                    </div>

                </li>

            {% endfor %}

        </ul>


        {% if paginate.totalPages > 1 %}

            <nav class="nav nav--pagination">

                <ul class="nav__list">

                {# <a href="{{ paginate.firstUrl }}">First Page</a> #}
            {# {% if paginate.prevUrl %}<a href="{{ paginate.prevUrl }}">Previous Page</a>{% endif %} #}

            {% for page, url in paginate.getPrevUrls(5) %}
              <li class="nav__item">
                <a href="{{ url }}" class="nav__link">{{ page }}</a>
              </li>
            {% endfor %}

            <li class="nav__item nav__item--active"><span class="nav__link">{{ paginate.currentPage }}</span></li>

            {% for page, url in paginate.getNextUrls(5) %}
                <li class="nav__item">
                    <a href="{{ url }}" class="nav__link">{{ page }}</a>
                </li>
            {% endfor %}

           {#  {% if paginate.nextUrl %}<a href="{{ paginate.nextUrl }}">Next Page</a>{% endif %}
            <a href="{{ paginate.lastUrl }}">Last Page</a> #}

                </ul>

            </nav>

        {% endif %}

        {% endpaginate %}

        {% endcache %}  

    {% endblock %}

    {% block sidebar %}

        {% include '_partials/newsletter-signup' with { grid:'false' } %}

        {% include '_partials/social' %}

    {% endblock %}

If this all looks normal, I guess it is a bug with Craft?

6
  • Any updates on this issue, harmish?
    – carlcs
    Feb 5, 2015 at 11:45
  • Kind of. P&T looked in to it but were unable to re-produce the problem reliably so it's not something that's going to be fixed in any sort of time-frame, as far as I can tell. Feb 9, 2015 at 13:53
  • Looks like this is doomed to linger unless the problem magically fixes itself. I've had a similar issue with rather meaty sub-templates, but that doesn't seem relevant here. Would you mind adding your Craft version and clarifying what environment(s) are pertinent here, if only for posterity?
    – Matt Stein
    Feb 20, 2015 at 2:18
  • It appears this was fixed in a recent Craft update :) Feb 27, 2015 at 9:24
  • I'm actually still experiencing problems with this so not sure if it was indeed fixed. Mar 3, 2015 at 12:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.