1

I want to use asset rev in my template, but only if plugin is installed and enabled:

    {% if craft.app.plugins.getPlugin('assetrev') is not null and craft.app.plugins.getPlugin('assetrev').isInstalled %}
        {% set fileName = rev(file) %}
    {% else %}
        {% set fileName = file %}
    {% endif %}

Hovewer when i disable plugin, mere existence of rev function in my template, still causes error.

| improve this question | | | | |
1

you can check if the plugin is installed and enabled with:

{% if craft.app.plugins.isPluginEnabled('assetrev') %}
  {% set fileName = rev(file) %}
{% else %}
  {% set fileName = file %}
{% endif %}

you won't need the extra check craft.app.plugins.isPluginInstalled('assetrev') then.

isPluginEnabled():

Returns whether a given plugin is installed and enabled.

| improve this answer | | | | |
  • true, but using rev in templates still causes error. – piotrpog Jun 27 '19 at 6:33

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.