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

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

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'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 netcarver
      Part 1 of a 2 part Module & Service Reveal.
      I'm currently working on a new module: ModuleReleaseNotes that was inspired by the work I originally did on making Ryan's ProcessWireUpgrades module "release" aware. In the end, I decided to ditch the approach I was originally taking and instead work on a module that hooked in to the UpgradeConfirmation dialog and the module edit page.
      Aims
      My aims for this module are as follows...
      Make discovery of a module's changes prior to an upgrade a trivial task. Make breaking changes very obvious. Make reading of a module's support documentation post-install a trivial task. Make module authors start to think about how they can improve the change discovery process for their modules. Make sure the display of information from the module support files/commit messages doesn't introduce a vulnerability. Looking at these in turn...
      Making discovery of a module's changes prior to upgrade a trivial task.
      This is done by adding a "What's changed section" to the upgrade confirmation dialog.  This section takes a best-effort approach to showing what's changed between the installed version and the updated version that's available via the module repository.
      At present, it is only able to talk to github-hosted repositories in order to ask them for the release notes, the changelog file (if present) and a list of commits between the git tag that matches the installed version and the tag matching the latest version.
      It will display the Release Notes (if the author is using the feature), else it will display the commits between the tags (if tagging is used by the module author) else it will show the changelog file (if present) else it will show the latest N commits on the master branch (N, of course, being configurable to your liking.)
      An example of the Github Release Notes pulled in for you, taken from Mike Rockett's TextformatterTypographer Module...

      An example of a tag-to-tag commit list from the same module...

      An example of a changelog - formatted to show just the changes (formatting styles will change)...

      Finally, an example of a fallback list of commits - sorry Adrian ...

       
      Making breaking changes obvious.
      This is currently done by searching for a set of configurable search strings. Later versions may be able to support breaking change detection via use of Semantic Versioning - but this may require some way of signalling the use of this versioning standard on a module-by-module basis.
      For now, then, you can customise the default set of change markers. Here I have added my own alias to the list of breaking change markers and the changes section of the changelog is styled accordingly (these will be improved)...

       
      Make reading of a module's support documentation, post-install, a trivial task.
      This is done by making some of the support files (like the README, CHANGELOG and LICENSE files) readable from the module's information/settings screen. There is an option to control the initial open/closed state of this section...

      Here is Tracy's README file from within the module settings page... 

       
      Make module authors start to think about how they can improve the change discovery process for their modules.
      There are notes in each of the sections displayed on the upgrade confirmation page that help authors use each of the features...

       
      Make sure display of external information doesn't introduce a vulnerability.
      This is an ongoing concern, and is the thing that is most likely to delay or prevent this module's release lead to this module's withdrawl should a vulnerability be found. Currently, output is formatted either via Markdown + HTML Purifier (if it was originally a Markdown file) or via htmlspecialchars() if it has come from a plaintext file.
      If you discover a vulnerability, please get in contact with me via the forum PM system.
       
      Ongoing...
      For now, I've concentrated on integration with GitHub, as most people use that platform to host their code. I know a few people are hosting their repositories with BitBucket (PWFoo comes to mind) and some with GitLab (Mike Rockett?) and I would eventually like to have adaptor implementations for these providers (and perhaps GitKraken) - but for now, GitHub rules and the other hosts are unsupported.
       
      Links
      Github: ModuleReleaseNotes
      PW Module Repository: Here
    • By FrancisChung
      Hi,
      I was wondering if anyone knew what this did? 

      If so, do you know what modules it actually impacts? Is there another log that lists the action it took?

      I'm having some weird problems with PHP duplicate declaration per link below, since this module was run.
       
       
    • By tpr
      AdminOnSteroids
      Various admin tweaks to enhance ProcessWire admin.
      http://modules.processwire.com/modules/admin-on-steroids/
      https://github.com/rolandtoth/AdminOnSteroids

    • By Macrura
      Field Descriptions Extended
      This module enables you to extend field descriptions by dividing short descriptions with a longer text that is revealed in a toggle.
      Github: https://github.com/outflux3/FieldDescriptionsExtended
      Extending your field descriptions using the standard field's description field.
      Once this module is installed, it will automatically search your description field for the presence of 5 dashes (-----).
      Any content above the 5 dashes will be visible and the content below the dashes will be hidden. A 'More...' link will appear at the end of the short description which when clicked will reveal the rest of the description.
      Using Simple Markdown Editor with the description field
      If you have Simple Markdown Editor (InputfieldSimpleMDE) installed, you can enable the field description to have that editor.
      *When using Simple MDE, you can use the button (Insert Horizontal Line) instead of typing 5 dashes. More about SimpleMDE.
      Extending your field descriptions using content from a ProcessWire Page for the field description.
      You may use the content from a ProcessWire page as a field description. This would allow you to easily insert images, links, and use hanna codes.
      To use page content for your field descriptions, please follow these instructions:
      Install Select Fields module (FieldtypeFields) http://modules.processwire.com/modules/fieldtype-fields/ Create a new field using this field type, e.g. field_select. Add the field to any template you will be using for your field descriptions. Setup your help pages (for example under a settings branch) where you will store the field description content,using the template containing the Field Select. Add content to a page and select the field where that content should show. To show a short text before the link to the longer content, separate them with 5 dashes Be sure to update your settings on this page, first enable page content descriptions,then specify the name of the Select Fields field, template to search, and content field. If you create a field description using this method, please note that the description field must be blank for contexts where you want the page content to appear.
      You can freely use template context for field descriptions, but the Page Content method is not context sensitive and will display under all contexts where the description is blank.
      ----
      original post:
      This is a new module, hope to release soon, which allows extended field descriptions, in currently 2 ways.
      The main feature of the module is that you can have a short description and then a 'more...' link which drops down a longer block of text.
      This is achieved by separating the intro/visible text and the rest with 5 dashes.

      Example setup:

      the 2nd way is if you are using AdminThemeUiKit, you can show extended field instructions in a panel. The content of the panel is edited on a regular PW page. This use case would probably not be that common, but if you had a field that required some extended instructions for how to use, this could be useful; Also, since this allows you to target information and instructions down at the field level, it could reduce the amount of documentation needed on a global level, since it is a lot more context targeted.