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 Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot: