Skip to main content
added 10 characters in body
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

The onlyOne thing you could do is to cache the individual entrieseach entry individually:

{% set categoryProducts = craft.entries.section('products').relatedTo(category) %}
{% set categoryProducts = shuffle(categoryProducts) %}

{% for entry in categoryProducts %}
    {% cache globally withusing key 'product-' ~ entry.id %}
        ...
    {% endcache %}
{% endfor %}

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

The only thing you could do is to cache the individual entries:

{% set categoryProducts = craft.entries.section('products').relatedTo(category) %}
{% set categoryProducts = shuffle(categoryProducts) %}

{% for entry in categoryProducts %}
    {% cache globally with key entry.id %}
        ...
    {% endcache %}
{% endfor %}

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

One thing you could do is to cache each entry individually:

{% set categoryProducts = craft.entries.section('products').relatedTo(category) %}
{% set categoryProducts = shuffle(categoryProducts) %}

{% for entry in categoryProducts %}
    {% cache globally using key 'product-' ~ entry.id %}
        ...
    {% endcache %}
{% endfor %}
added 337 characters in body
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

The only thing you could do is to cache the individual entries:

{% set categoryProducts = craft.entries.section('products').relatedTo(category) %}
{% set categoryProducts = shuffle(categoryProducts) %}

{% for entry in categoryProducts %}
    {% cache globally with key entry.id %}
        ...
    {% endcache %}
{% endfor %}

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.

The only thing you could do is to cache the individual entries:

{% set categoryProducts = craft.entries.section('products').relatedTo(category) %}
{% set categoryProducts = shuffle(categoryProducts) %}

{% for entry in categoryProducts %}
    {% cache globally with key entry.id %}
        ...
    {% endcache %}
{% endfor %}
Source Link
andrew.welch
  • 11.6k
  • 24
  • 31

The {% cache %} tag only caches the HTML output. That's it.

In your example above, nothing is cached, and categoryProducts will be an empty set.