A Cookie Consent Modal for Kirby3

:wave: Hey there. Looking for an easy customizable cookie modal thing?
There you go:

12 Likes

Looks great! Very nice. :muscle:

Haven’t tested it yet, but what is your proposed workflow for style override?

EDITED:
Ah, sorry, just saw it. Just CSS. Perfectly ok.

1 Like

Hey! Thank you for that great plugin! I have just tested everything and it seems to work very fine, so far with the current release of firefox! I have just noticed one thing, maybe you can assist me here: under Chrome (v. 87), and the current Edge release, the cookiebanner reappears on every subpage loaded. Also, if I intercept the cookie status, the cookies are not saved for the subpages. Thank you for your help!

Hey @Chimara2501 thank you for your kind words.
Which version of the plugin is currently installed? And do the features appear in the cookie panel (see screenshot)?
Otherwise, I just tested the plugin again with the Kirby Starterkit (3.5) in Chrome (version 87.0.4280.141) and Edge (version 87.0.664.75) and could not reproduce the described behavior.

You are very welcome, really nice work, and I did not find anything comparable! Also, thank you for that ultra quick reply! I checked the version and noticed, that there was a new release since September (this is when I downloaded and tested your great plugin first). I updated to the current version and voilá: Everything works! Again, thank you!

1 Like

Hi again! After some time of testing of your great plugin, I have recognized another issue: the google analytics code, I have implemented, only loads when the site is beeing reloaded, after the cookie function is accepted.

I have used this code to include the tag into the head of the site:

<?php if (isFeatureAllowed('analytics')): ?>
<!-- Global site tag (gtag.js) - Google Analytics --> 
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script> 
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXXXX-X');
</script>
<?php endif; ?>

Can you help me here? Thank you in advance!

1 Like

I actually wouldn’t call it a issue, but rather a missing feature. Without reloading the page, the JavaScript for Google Analytics would have to be intercepted and not released until the cookies are agreed to.
Theoretically, you can implement the logic for this yourself and listen for the cookie update event: 01 How to set it up · michnhokn/kirby3-cookie-banner Wiki · GitHub
(Feel free to make a pull request :D)

As a quick fix for now, I would recommend reloading the page automatically after a cookie update. The code for this could look like this:

<script>
document.body.addEventListener('cookies:saved', function() {
    window.location.reload();
});
</script>

Thanks for all the praise on the plugin. I’m very happy if I can help Kirby users with it.

1 Like

Hey there! Thank you so much, I have researched by myself now for several hours and understood the logic of that now, too! You will never stop learning :slight_smile:

Anyhow the Reload Script works pretty fine so far, thank you for that super easy solution!

1 Like

Hey, thanks a lot! I’m glad if I could help. Thanks also for the input. If I find time, I will try to integrate the feature.

Hi @michnhokn,
just installed the plugin via composer & included the snippet before closing body tag:

<?php snippet('cookie-modal', [
    'assets' => true,
    'showOnFirst' => true,
]) ?>

Everything seems to load ok, but the cookie modal div always has a class of cookie-modal--hidden. Is there something I’m missing?

Edit: My Bad. I accidentally had two footer snippets on my page. Sorry for the confusion…

1 Like

I do have a question now, though. Is it possible to change the text of the modal without enabling a multi language setup?

1 Like

Sorry @bruno. Currently you have to activate the languages to change the content. I’ll add it to the ToDo list. I will release a new version during the week, where you can customize it.
Thanks for the input!

1 Like

Amazing! Thanks for this plugin, it’s been a real time saver.

any news on this? would be great…

@bruno @matthack

I was unfortunately very busy the last few days. But here is the release:

3 Likes

:tada:

1 Like

wow - this was fast! Thanks.

1 Like

@michnhokn fantastic plugin, thanks for making it - it helps me a lot of controlling cookies on my project.

So far I could implement everything, is there a possibility (and how) to create a link to call again the modal box? I’d like to add the button “change cookie settings” at bottom of my page (sorry for the stupid question, I’m rather new with php/js :grimacing: )

Thank you for the compliment. I’m always happy when I can take work off with the plugin.

Check it out here: 01 How to set it up · michnhokn/kirby3-cookie-banner Wiki · GitHub. I have a short section about it in the repo wiki. Hope that helps you. Otherwise feel free to contact me again.

1 Like

That helped indeed - gotta read the stuff more thoroughly :slight_smile: