Closed ballmannweber closed 3 years ago
Absolutely! Have a look here: https://github.com/elleracompany/craft-cookie-consent/issues/18
oh great, I will take a look at this! thank you very much for the quick reply!
I tried this out and it seems to function. since I am not very familiar with javascript here are the steps I took for double checking:
replacing {% hook 'before-body-end' %} with {{ craft.blitz.getTemplate('primary/consent') }} which point to my consent template. I already had a custom tempate so that was easy.
copying the Cookie Consent JS to my assets and replacing the first line with document.addEventListener('afterBlitzInject', function () {
turning off the "Load JS Assets" in the plugin
inserting the modified js into my template with {% do view.registerJsFile('/assets/js/craft-cookie-consent.js') %}
why can’t I just include the js with a normal script tag like ? and is there a way to include the {{ alias('@web') }} before the /assets/js… so that always the complete url will be called?
thank you!
Hi, great that you got it working.
You could just register it as a regular script file, no problems. This is just the craft/yii-way to inject scripts, and has the added benefit of not rendering the same script twice. You can also just add @web inside the function, as it is parsed as an alias.
{{ craft.blitz.getTemplate('@web/primary/consent') }}
we are using the blitz cache plugin and wanted to use your cookie consent plugin but we ran into issues because the cached pages don’t recognize if a user accepts some kind of setting – the dialog will be displayed forever.
any ideas for a solution?