Can

MarkupCookieConsent

Recommended Posts

Still some work needed, but I just pushed the whole new version to GH and renamed it as MarkupCookieConsent.
https://github.com/CanRau/MarkupCookieConsent/ (beta)
 
It's now doing everything on it's own, means there are no externals involved.
 



 
EDIT 1: Added screenshot to repo
 
EDIT 2:

  • Okay, I would say anything works (at least in Chrome on Mac) except the translatable config fields. Both themes are ready having each 2 available positions (top/bottom).
  • Extended screenshots to show all 4 versions
  • Added readme
  • Added to module directory http://modules.processwire.com/modules/markup-cookie-consent/

EDIT 3: Lanaguage fields will work using this patch from Ryan, or you can just wait for the next PW devns release (probably on friday)

Changelog

  • 0.0.9 - Changed style injection, now prepends to first <link> in head makes it easier to add custom css tweaks without the need for !important because of the cascading order
  • 0.1.1Fixed issue with cookie not being set, two strings wouldn't recognize translation, default cookie expire now 1 year, updated readme
  • 0.1.2 - Added minified CSS & JS
  • 0.1.3 - don't remember what changed in this version
  • 0.1.4 - cookie bar now fully translatable, added devns branch which is meant to be used with PW 3.x devns as it adds namespaces
  • 0.1.5 - fixed issue on single language installations


 
Still have to test some things. For example, you can now select a page from your tree as policy page using InputfieldPageListSelect instead of entering the url, so now the link should work with multiple languages, too. Though I haven't exactly tested it yet!
 
The language fields draw my attention. They look nice but only default language is saving at the moment.
So this is how I build the config fields using MarkupCookieConsent.config.php file
I kept only settings for one field..

public function getDefaults() {
    return array(
    'messageText' => __("This website uses cookies to ensure you get the best experience on our website"),
    );
}
public function __construct() {
    $this->add(array(
        array(
                'type' => 'text',
                'name' => 'messageText',
                'label' => __('The message shown by the plugin'),
                'useLanguages' => true,
                'columnWidth' => 70
            )
        )
    );
});

I'm not sure if/how I need to define default values for languages, too? I checked some other modules from Ryan but there he still uses the config field building ways getConfigInputfields() for example, so those are not really applicable, are they?
So visually everything looks good, even when inspecting the fields the field names seem to be alright..
Or is this approach not yet multi lang capable?
 
Everything else should work already. Ah except for the Default settings button at the bottom. It's more like to-do list for myself ;-)
 
Ah and regarding "dependencies". When "Enable Ajax" checked, the form will be submitting using ajax (magic! haha), anyway..just to let you know it's using plain vanilla js so no jquery or anything else needed. Although it should work well, it's only tested in newest Chrome on Mac and the script is not handling errors. It's actually removing the cookie information right after the click and then making the request. So worst case would be, considering any error, the message popping up again even so the user thinks he already agreed...
 
I figured it's probably not the kind of module which many will use, cause when you're a little into PW you now how to easily include such an information yourself. But for me it's especially practicing PHP..
 
So I would really love to get some hint on the language fields :)

Side note: For everyone interested in disabling cookies at all to avoid every possible need for this plugin checkout out this blog post from Ryan http://processwire.com/blog/posts/multi-instance-pw3/#more-session-control

  • Like 4

Share this post


Link to post
Share on other sites

Thought might be good to reply myself to let you now there is a lot going on here :)

Share this post


Link to post
Share on other sites

Hi can,

Thank you for the module. It would be great to have a description of what the module does or a screenshot

  • Like 1

Share this post


Link to post
Share on other sites

I think your language question is around sites displayed in multiple languages (multi language fields etc) rather than translating the module itself into other languages? If so then that is a little tricky I guess - you'd need to iterate the languages and store a message for each language - this code may help: https://processwire.com/talk/topic/4383-how-to-set-language-active-via-api/?p=42956

Please feel free to submit it to the modules directory as it is though - it'll give it better visibility and possibly more feedback :)

  • Like 1

Share this post


Link to post
Share on other sites

Your right BernhardB! Got a little stuck with the code, so making screenshot and readme felt a little wrong..but it would make the post a little more attractive I guess.
Now we're having a little selfmade chocolate snack and afterwards I'm preparing something ;-)

Thank you Pete, but it's actually the opposite (or your "rather than.." part ;)), means I want the module config fields to be translatable on the config screen.

EDIT: couldn't let you guys wait any longer so I quickly added a screenshot to the repo. More is coming soon.

Edited by Can
  • Like 2

Share this post


Link to post
Share on other sites

Erm... But your screenshot shows what I meant? The "rather than" bit I mentioned is translating the module instructions not the output message.

Either way, it's all good, and would actually be something that could be added to other modules as well - nice work.

  • Like 1

Share this post


Link to post
Share on other sites

-.-  haha

yeah it looks nice..but actually only the default languages fields are getting saved..so I don't know what I need to do to have it save all..

Thank you :)

And as I said, I need to test a little more, for example I don't know what it does when in single language environment. Maybe I need to make 'useLanguages' conditional..

Haven't testet privacy policy page settings yet. But after lunch I'll go and check it all out..than maybe add to module directory.

Share this post


Link to post
Share on other sites

Updated first post (4 screenshots now, readme and code fixes)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your work, Can, works fine! 

Would mention, that we (fortunately) don't need to show this info-panel for data which is relevant for the website (if I read the EU law correctly).

Otherwise, it would be very annoying to see these info-panels on every 2nd website ;-)

Share this post


Link to post
Share on other sites

Glad you like it Jugibur :)

Don't really get what you mean? What website relevant data? Front or back-end?

Share this post


Link to post
Share on other sites

They (EU) say, that websites with necessary cookies (like for shops or some kind of forms, etc.) don't need to show this hint-panel to users.

You need it only, if you kinds of user tracking or advertising across a network.

Additionally, Google 2015 have made the oblication to show this cookie-hint to users, if they use AdSense.

See: https://support.google.com/adsense/answer/6245892?hl=en

Share this post


Link to post
Share on other sites

Sorry but I still don't get you exactly?

You whant to be able to enable the hint only on selected pages via module config?

As far as I understand you need this information always when you use cookies for whatever reason..but maybe I'm wrong?

And the module inserts this info only as long as the user didn't accept it. After accepting the message won't show up again..

Share this post


Link to post
Share on other sites

If a cookie consent is really needed is a questions for lawyers, but I've also read that the law should (at least in theory) only be applicable to cookies, which are not critical to the websites functioning (login/carts). Anyway, I'd say that's not the topic to further discuss here.

Share this post


Link to post
Share on other sites

bumped version -> 0.0.9

Changed style injection, now prepends to first <link> in head makes it easier to add custom css tweaks without the need for !important because of the cascading order

Still need to get the language fields to work  O0

Edited by Can
  • Like 1

Share this post


Link to post
Share on other sites

Hi Can

works nice and translation in default language works also (except 2 strings).

Additional you can make line 54, 55, 66, 67 translateable.

Line 98 and 217 is not working.

When using single quotes, it works but without the newline \n

Share this post


Link to post
Share on other sites

Just realized that the first post links to the old deprecated version..maybe I should delete it altogether..

Don't really know to what lines you refer?

Line 54  https://github.com/CanRau/MarkupCookieConsent/blob/master/MarkupCookieConsent.module#L54 is the hook..

Normally everything should be translatable via module config, but for whatever reason I still don't get it workin.. 

Share this post


Link to post
Share on other sites

in MarkupCookieConsent.config.php

line 54, 55

'dark' => __('dark (Default)'),
'light' => __('light')

line 66, 67

'top' => __('top'),
'bottom' => __('bottom (Default)')
  • Like 1

Share this post


Link to post
Share on other sites

Kay those 4 are now translatable (already pushed to gh)

But I hav to investigate a little further why they not properly work..got another project to finish first..

But any hint is always welcome ;-)

PS: Actually I planned to include a german translation file in the repo in the first place, but never made it  :'(

  • Like 1

Share this post


Link to post
Share on other sites

Hi, 

Thanks for the great Module.

Just letting you know that in your css file

form {
    margin-bottom: 20px;
}

is pushing the bottom banner up abit.

When I remove it, it looks better.

Share this post


Link to post
Share on other sites

I answered already on GitHub, don't know where you found this rule?

Share this post


Link to post
Share on other sites

I've made a first translation file for german: GitHub

All strings are translatable, but

line 98 ist not working:

'notes' => sprintf(__("For example Font Awesome checkmark icon e.g. %s\n(You need to include Font Awesome on your own)"), "<i class='fa fa-check'></i>"),

with single quotes it works, but without the newline \n.

Maybe don't use the \n? Or delete part of string "(You need to include Font Awesome on your own)", because Font Awesome is already included in PW.

same problem with line 217:

'notes' => __("Default true\nIt has been suggested that this setting can effectively help to reduce identity theft through XSS attacks"),

  • Like 2

Share this post


Link to post
Share on other sites

Thanks to Ryan the language fields on MarkupCookieconsents option work with this patch for devns.

So either apply yourself (like I did) or wait for the next release, probably coming on friday.

https://github.com/ryancramerdesign/ProcessWire/commit/2fe134b7b059fff023f0f37c7f172a9853c88af2

You only need to update ProcessModule.module from the linked GitHub page, the other fix is as mentioned in the title not needed for the language fields to work.

  • Like 4

Share this post


Link to post
Share on other sites

good question but no

may I ask why?

maybe check out those

https://processwire.com/talk/topic/9324-hook-to-suppress-setting-of-session-cookie/

https://processwire.com/talk/topic/4756-stop-cookies-being-sent-session-start-for-site/

First I thought I need to provide the possibility to the users to disable cookies..but now I figured soo many pages depend on cookies, and the cookie law seems more about unnecessary data about the user..but as stated in the second thread by Ryan you could use ProCache or own implementation to bypass "everything" (php, mysql) so no cookies will be set..

Share this post


Link to post
Share on other sites
I've this problem with that site: cookie isn't created.

All other cookie are created but not this.

Production site (linked) now use ProCache so it is right.

But dev site with ProCache disabled has the same problem. 

It works for a while.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By kixe
      Email Verification
      This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date.
      Download
      https://modules.processwire.com/modules/email-verification/
      API
      // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE
      $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file:  blacklist.txt
       
    • By teppo
      Code Blocks Textformatter is a tiny Textformatter module I cooked up to add support for code blocks to text/textarea/RTE fields on some of the sites I work with. Unlike a full-blown Markdown Textformatter – which is something that we already have in the core – this module simply adds support for fenced and inline code blocks.
      The syntax is based on the GitHub code block documentation, so please refer to that for additional instructions. The README at GitHub also includes some basic examples. As with any Textformatter, in order to enable this one, install it and enable it via field settings. Note that there's no syntax highlighting built in (at least for the time being), so use a tool of your choice for that – personally I prefer Prism.js.
      Since this module doesn't use a Markdown tool behind the scenes, but rather some home baked regular expressions, there's always the possibility that I've missed something – but please let me know if you use this module and run into any issues. On the other hand this module should be relatively fast and unobtrusive, as there are no unnecessary bits of code to run 
      GitHub repository: https://github.com/teppokoivula/TextformatterCodeBlocks Modules directory: http://modules.processwire.com/modules/textformatter-code-blocks/
    • By theo
      Here is my first processwire module (beta).
      https://github.com/theo222/ImagePickerField
      A lot of "first times". First time Github, Markdown and of course PW Modules.
      So be gentle please.
      I hope it works.

    • By horst
      Image Animated GIF  v 2.0.2
       
      Module for PW 2.5 stable or newer, but is obsolete for PW Versions greater then 3.0.89 (... read more ...)
       
      This module helps with resizing and cropping of animated GIFs when using the GD-Library.
      The GD-Library does not support this.


      This module is completely based upon the fantastic work of

         László Zsidi (http://www.gifs.hu/, builts the initial classes)
         xurei (https://github.com/xurei/GIFDecoder_optimized, enhanced the classes)


      I have ported it to a PW module and it works with core imagefields, together with Pia and with CropImagefields that uses the new naming scheme since PW 2.5.
       
      ------------------------------------------------------------------------------------------------------------------------------------------
      read more in this post about the rewrite from version 1.0.0 to version 2.0.0
      ------------------------------------------------------------------------------------------------------------------------------------------
      You can find it in the modules directory: https://modules.processwire.com/modules/image-animated-gif/
      and on Github: https://github.com/horst-n/ImageAnimatedGif
      ------
      A preview can be found here