1

I'm having an issue where I am getting template errors related to my craft cache tags in some environments but not others. I have my site set up on a production server that is a Linode/Forge setup. The site works fine there.

Locally I am using a Homestead/Vagrant setup and I am getting template errors on any pages that use the cache tag.

Here's the code that is having the error:

{% extends "_layout" %}


{% block pageStyles %}

{% for entry in craft.entries.section('juices') %}
    .color-nameplate.btn-{{entry.slug}} {
        background-color: {{entry.productColorCode}};
    }
{% endfor %}

{% endblock %}

{% block bodyClass %}home-page{% endblock %}


{% block content %}

{% cache if craft.config.cache %}

{% for row in entry.bodyBuilder.level(1) %}
    {% include 'bodyblocks/' ~ row.type.handle with {row: row} %}
{% endfor %}

{% endcache %}

{% endblock %}

This code works in the production environment but not on local. On local it is showing the following template error:

Unexpected token "name" of value "craft" ("end of statement block" expected).

If I remove the cache tags then the template displays, but this won't work for my production environment so I need to work out what the issue is.

Thanks,

Brian

2

So you're accessing craft.config.cache but unless you've actually added your own cache config setting in craft/config/general.php that's not going to work. There's no cache setting in Craft's Config Settings

So the reason it works on live production is it's a soft error, and you have devMode off, so it continues to work. In local dev, presumably you have devMode on, so it rightly errors.

For more information on Craft cache tags, you can read the The Craft {% cache %} Tag In-Depth article.

0

Have you tried to activate development mode under craft/config/general.php?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.