News:

Wondering if this will always be free?  See why free is better.

Main Menu

Tempate related question

Started by connecticut472, December 05, 2014, 12:53:02 AM

Previous topic - Next topic

connecticut472

I'm currently working on integration some caching behaviour using {% cache %} tags. This works mostly just fine, but I have some issues when I work with related entries.

For example I have a list of categories with an indicator to show many entries they are assigned to.

    New (3)
    Used (2)
    Broken (3)

If I change an entry and add a category, the cache refreshes and shows the correct amount. But if I remove a category from an entry I get the wrong number until I refresh the cache manually.

Is this the expected behaviour? Or do I miss something here?

Here is my code exmaple:

{% cache unless not craft.config.cache %}
{% set categorySlug = productSection ~ 'Categories' %}

<ul>

{% for category in hxxp:craft.categories.group [nonactive](categorySlug) %}
  {% set entryCount = craft.entries.relatedTo(category).total() %}
  {% if entryCount > 0 %}

    <li>
      {{ category.title }} ( {{ entryCount }} )
    </li>

  {% endif %}
{% endfor %}

</ul>

{% endcache %}

Deaks

in honesty to me it sounding like its doing what it should if you have cache enabled
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Advertisement: