Closed ghost closed 4 years ago
Hi,
Thank you for reaching out.
I have yet to test Blitz out, so unfortunately I’m not that familiar with it just yet. I would suggest trying to use the function {{ craft.blitz.getTemplate('template/name', params) }} instead of {% hook 'before-body-end' %}.
This will require you to have a copy of the cookie consent twig inside your template folder (you can copy templates/banner.twig from the plugin folder) and then pass that into the blitz function. The twig should then be able to render the correct markup.
Please try this out and let me know if it works, and I’ll test this and create a section in the docs for this as soon as I have time.
Hello,
I was able to get it to work, thanks to the many settings you have. After adding the template with the Blitz twig tag I need to load a modified Cookie Consent JS file. Blitz registers new event handlers, so I used on that fires after the injection. Sweet. 🍭
document.addEventListener('afterBlitzInject', function () { ... })
I switched off the plugin js for my site(s) and added my altered one with this Craft twig function.
{% do view.registerJsFile('/js/cookie_consent_script.js') %}
From what I can see Cookie consent is working and I have a Blitz ⚡️ fast site again! Double win.
Thank you very much for your help.
Great!
I will close this issue. Please do not hesitate to reach out again should you encounter any other issues.
Hey just want to add to the knowledge captured here to possibly save someone else the time if they made the same mistake.
I thought I should add {{ craft.blitz.csrfInput() }}
to the template, however since we're fetching the template via ajax already at runtime this is unnecessary and fails. Keep the regular craft {{ csrfInput() }}
function in the template.
Hello, I'm evaluating your plugin for a multisite configuration and so far I really like the plugin. In our setup we want to use the Blitz plugin for Craft as well. When active, cookie consent is not working anymore, due to the static caching. Do you have a solution to reactivate it?
There is a section in the Blitz docs regarding dynamic content, but I'm not sure if that would be a solution to the problem.
Blitz: https://putyourlightson.com/plugins/blitz Blitz dynamic content: https://putyourlightson.com/plugins/blitz#dynamic-content
Thank you very much for your work on the plugin an any helpful tip.
Best regards
Mike