This module is used for displaying a Cookie Compliance window at the top of the website.
The goal of the module is to be easy to configure and style to fit any website.
Features
- Displays a cookie compliance window at the top of the website.
- Settings page so you can easily access the text in the window.
- Multilingual, the settings page will generate forms for every language that is enabled on the installation.
- Responsive.
- Works with and without JavaScript enabled.
How it works
When you first enable the module, you will need to configure and style the cookie compliance window (See below). After you have done that, a window will appear if the user hasn't accepted yet.
At the moment it works as such that if you navigate to another part of the page or click the button, the module will automatically set a cookie saying that the user has accepted the cookie compliance law.
Configuring Cookie Message
After you have enabled the module, go to admin/config/system/custom-cookie-compliance.
Once there you can collapse the fieldset named after the language you want to edit the message of and type in what ever you wish. Then type in a text for the button, something along the lines of "I Agree." then click Save and it should be ready and working.
An easy way to test if it works is to open an incognito window in Chrome and then go to your site and then it should pop up.
Styling
The following code snippets are the only rules that you are going to need to interact with in order to get the window to look pretty on your site. Simply create a CSS file and add these rules.
The max width that is set on .cookie-compliance__inner is the page's max width, so if you have a page that is XXXpx wide and you want the cookie window to follow the same width set to XXXpx.
.cookie-compliance__wrapper {
background-color: red;
}
.cookie-compliance__inner {
max-width: 1024px;
}
.cookie-compliance__text {
color: #fff;
}
.cookie-compliance__button {
background-color: #000;
color: #fff;
}Related modules
There is a module called EU Cookie Compliance (https://www.drupal.org/project/eu_cookie_compliance) which I tried myself, but found it to be unnecessarily hard to configure.
My module allows the admin to style the element however they want with CSS instead of in a settings page like EU Cookie Compliance. There is also easy multilingual support, which allows the admin to type messages for every enabled language on the page. It works with and without JavaScript. And I would say that it is cleaner overall.
Links and misc.
Sandbox project page: https://www.drupal.org/sandbox/jayza/2448801
git clone git://git.drupal.org/sandbox/jayza/2448801.git custom_cookie_compliance
Reviews:
1) https://www.drupal.org/node/2448653#comment-9707617
2) https://www.drupal.org/node/2316301#comment-9707687
3) https://www.drupal.org/node/2351269#comment-9707741
Comments
Comment #1
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxjayza2448801git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
jzasnake commentedI have updated and fixed all the errors that popped up in the PAReview bot's review. Although I cannot fix the git error for the 7.x-1.0 branch although I have created a new 7.x-1.x branch.
Comment #3
jzasnake commentedComment #4
leopathu commentedHi,
I have found the following issues from your module.
1. Write properly the git details in project applications issues
2. Use proper package name in the .info file Instead of Package = Custom
3. If you adding the css and js from .info file, it will load on all pages, best to add necessary pages from .module file by using drupal_add_js()
Other things are ok for me.
Comment #5
leopathu commentedComment #6
jzasnake commentedHi Leopathu,
I have a question concerning the second item, what do you mean by using a proper package name? Are you saying that I should change the project name completely? And if so, why?
Ill get to the other stuff tomorrow.
Comment #7
naveenvalecha@leopathu,
The above ones are not blocker.Is there anything else that you found that stopped you to set this to RTBC
@jzasnake,
Regarding point #3 You are adding js/css files in .info file.Is is needed at all pages.Please add a comment.If not use hook_page_alter or its friends to render it on specific pages.Use #attached to add the JS/CSS file
with page rendered array where these actually required.
No Packagename is used distinguish the modules on the modules listing page on the basis of their categories, If you will not define the package name then module will display in default category 'Other'
Comment #8
jzasnake commented@naveenvalecha
Thanks for clearing that up for me! I have now removed the JS/CSS includes from the info file and instead added them via #attached array rendering in my hook_page_alter function.
Comment #9
naveenvalechaAs all reviewers are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Comment #10
jzasnake commentedComment #11
jzasnake commentedComment #12
joshi.rohit100Manual review :-
As per the http://php.net/manual/en/reserved.variables.server.php,
may throw notice, if HTTP_REFERER is not available. So instead of checking for empty, use isset().
Apart from this I am not seeing any issue.
Also one more thing - Why haven't used behaviors in JS ?
Thanks and Regards
Rohit Joshi
Comment #13
klausiempty() does not throw PHP notices: "No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false." from http://php.net/manual/en/function.empty.php
Comment #14
jzasnake commented@joshi.rohit100
As klausi stated, empty() is essentially an equivalent to isset().
I am not familiar with behaviors, if you are referring to https://www.drupal.org/node/756722. But I will most certainly look in to it.
Comment #15
joshi.rohit100@klausi -
What my point here was that if $_SERVER['HTTP_REFERER'] is not set, then it will throw notice.My Apology for this.
Comment #16
jzasnake commented@joshi.rohit100
So is this RTBC?
Comment #17
jzasnake commentedComment #18
naveenvalechaModule authors can't directly set it RTBC.See the workflow https://www.drupal.org/node/532400
Comment #19
ollu commentedI've tested the module and it works pretty fine for me.
Comment #20
jzasnake commentedComment #21
mpdonadioAssigning to myself for next review, which will hopefully be tonight.
Comment #22
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit cefbcbf):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Minor; non-blocker.
Manual Review
(*) I think this technically has a CSRF in it. You rely on a GET parameter which sets a cookie in custom_cookie_compliance_preprocess_html().
Any site can spoof this link. Use the Form API instead.
(+) Your JS should be a Drupal behavior and not use the jQuery .ready() method.
You can move your config form to a separate include. This can help reduce memory footprint.
custom_cookie_compliance_preprocess_html(): use REQUEST_TIME instead of time;
The cookie expiration should be a configuration variable.
(+) You need a hook_uninstall() to get rid of the variables you are setting in _custom_cookie_compliance_settings_form(). Also keep in mind what cleanup may be needed as languages get added and deleted.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #23
jzasnake commentedI've updated the module according to @mpdonadio review.
Comment #24
klausiReview of the 7.x-1.x branch (commit 1f344ae):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
But otherwise looks good to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Assigning to er.pushpinderrana as he might have time to take a final look at this.
Comment #25
pushpinderchauhan commentedNo commit after 'commit 1f344ae', so same Automated Review.
I read through `git diff 1f344ae..HEAD` and also did a manual scan, and didn't see anything major. In addition to Klausi's recommendations, adding few more recommendations for you.
You should also really have a hook_help() with some basic info about the module.
You should move your setting form to a separate admin.inc/.inc file that is useful to keep all administration stuff like menu callbacks and forms etc. It's also useful for performance as well because all the functions from .module files get loaded at every initialization.
Otherwise it looks ready to go, so...
Thanks for your contribution, Jake Stanich!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.