Jump to content

MarkupCookieConsent


Can

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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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 ;-)

Link to comment
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

Link to comment
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..

Link to comment
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.

Link to comment
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
Link to comment
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

Link to comment
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.. 

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
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..

Link to comment
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.

Link to comment
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
×
×
  • Create New...