Closed MateThemes closed 8 months ago
Try update second line to this: {% for script in cookie.scripts %}
Just to check, i this is the cause of the error.
What version of October do you use?
I use October v3.
I changed the second line and now the banner works fine!
Thank you for your fast help!
But it is not a solution as this line is filtering disabled scripts.
I will test it in OC3 again as I do not use this version on production sites.
Thank you
What if you change the code to this:
` {% if cookiesSettingsGet('cookies',null)|length %}
{% for cookie in cookiesSettingsGet('cookies') %}
{% for script in cookie.scripts %}
{% if script.scripts_disable == 0 %}
{# If pages list is set, compare to current page URL #}
{% if script.scripts_run_pages == true and script.scripts_run_pages_list|length %}
{% set scriptRunThisPage = false %}
{% for item in script.scripts_run_pages_list %}
{% if url(item.page_url) == url().current %}
{% set scriptRunThisPage = true %}
{% endif %}
{% endfor %}
{% else %}
{% set scriptRunThisPage = true %}
{% endif %}
{# TODO: get rid of those IFs #}
{% if scriptRunThisPage %}
{# Test for production mode required first #}
{% if script.scripts_run_production == false
or ( script.scripts_run_production == true and this.environment == 'production') %}
{% if cookie.required or sgCookies[cookie.slug] %}
{% if script.scripts_code and scriptRunThisPage %}
{% put scripts %}
{{ script.scripts_code|raw }}
{% endput %}
{% endif %}
{% if script.scripts_file and scriptRunThisPage %}
{% put scripts %}
<script src="{{ script.scripts_file|media }}"></script>
{% endput %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %} `
Then I don't good the error and the filtering should work fine!
I will test it and update - but I would like to get rid of all those ifs :)
That would be the best to get rid of the ifs :)
I do a pull request. Do not more use "if" on "for " condition.
See this: https://github.com/twigphp/Twig/blob/40b6f59430cc17999406a5557c9e178704e92fa8/CHANGELOG#L135
Hello! I have following error on the smallgdpr plugin
Unexpected token "name" of value "if" ("end of statement block" expected).
~/plugins/janvince/smallgdpr/components/partials/run-scripts.htm line 5 {% if cookiesSettingsGet('cookies',null)|length %}`