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 Soma
      LogMaintenance
      A simple ProcessWire module to give some maintenance control over log files. I found myself often having lots of log files for different things that can grow more or less quickly to a size where they can be difficult to maintain. The built in Logger of PW does a good job of giving you the possibility to delete or prune logs. But it has to be done manually and sometimes a log grows into millions of lines, which makes it often impossible to even prune it as it's too large.
      LogMaintenance uses LazyCron to run the maintenance task and there's several settings you can setup on a global or per log basis.
      Archive: will create zip files for each log file in logs/archive/ folder and add the log each time the maintenance is run to a subfolder containing the datetime.
      Lines: keeps logs to a certain number of lines 
      Days: keeps the log to a certain number of days
      Bytes: keeps the log to a certain amount of bytes
      Each setting is checked from top down, the first setting to contain something is used. So if you check the "Archive" option, all other settings are ignored and logs are archived everytime the LazyCron is executed. If you want to keep your logs to a certain amount of bytes just leave all other settings to 0 or blank.
      Per Log Settings
      There's a textarea that you can use to setup a config for a specific log file one per line. All the logs you define here ignore the global settings above. The syntax for the settings is:
      logname:[archive]:[lines]:[days]:[bytes] 
      errors:1:0:0:0 // would archive the errors log messages:0:10000:0:0 // will prune the errors log to 10000 lines  
      The module can be found on github for you to check out. It's still fresh and I'm currently testing.
      https://github.com/somatonic/LogMaintenance
    • By teppo
      Fieldtype Page IDs is a third party Fieldtype that, simply put, stores Page references as integers (Page IDs).
      This fieldtype was built as a quick and dirty workaround for Page Reference fields' inability handle self-references due to circular reference issues. A project I've been working on for a while now includes a combination of RepeaterMatrix content blocks and tagging/categorization system that would've resulted in a lot of duplicate pages (and plenty of unnecessary manual work for content editors) had I used built-in Page Reference fields, and thus a new Fieldtype felt like the most sensible approach.
      Fieldtype Page IDs was designed to be loosely compatible with Page References in order to make conversions between the two feasible, but it is quite limited feature wise:
      largely due to the fact that stored values are actually just integers with no connection to Pages whatsoever some advanced selectors and related features are not supported, and page values can't be directly accessed configuration settings are limited to the bare essentials (selector string and Inputfield class) only a handful of Inputfields (AsmSelect, Checkboxes, Text) are (currently) supported Anyway, in case you need to store Page IDs (and Page IDs only) and are happy with the limitations mentioned above, feel free to give this Fieldtype a try. It has been working fine for me in one particular project, but hasn't been tested that much, so please tread carefully – and let me know if you run into any issues.
      GitHub repository: https://github.com/teppokoivula/FieldtypePageIDs
      Modules directory: https://modules.processwire.com/modules/fieldtype-page-ids/
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      I've updated the module to 0.0.4. I removed the instructions from this forum, so I don't have to maintain it on multiple places. Just checkout the readme on github 🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github. 
    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180528, v1.0.4 add custom select statement option 180516 change sql query method, bump version to 1.0.0 180515 multilang bugfix 180513 beta release <180513 preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By blynx
      Hej,
      A module which helps including Photoswipe and brings some modules for rendering gallery markup. Feedback highly appreciated
      (Also pull requests are appreciated 😉 - have a new Job now and don't work a lot with ProcessWire anymore, yet, feel free to contact me here or on GitHub, Im'm still "online"!)

      Modules directory: http://modules.processwire.com/modules/markup-processwire-photoswipe
      .zip download: https://github.com/blynx/MarkupProcesswirePhotoswipe/archive/master.zip
      You can add a photoswipe enabled thumbnail gallery / lightbox to your site like this. Just pass an image field to the renderGallery method:
      <?php $pwpswp = $modules->get('Pwpswp'); echo $pwpswp->renderGallery($page->nicePictures); Options are provided like so:
      <?php $galleryOptions = [ 'imageResizerOptions' => [ 'size' => '500x500' 'quality' => 70, 'upscaling' => false, 'cropping' => false ], 'loresResizerOptions' => [ 'size' => '500x500' 'quality' => 20, 'upscaling' => false, 'cropping' => false ], 'pswpOptions' => (object) [ 'shareEl' => false, 'indexIndicatorSep' => ' von ', 'closeOnScroll' => false ] ]; echo $pswp->renderGallery($page->images, $galleryOptions); More info about all that is in the readme: https://github.com/blynx/MarkupProcesswirePhotoswipe
      What do you think? Any ideas, bugs, critique, requests?
      cheers
      Steffen