Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
Having noticed the session cookie placed by the cart on my computer and only too aware of all the obligatory cookie warnings that one gets on all European commercial and other websites, and of the fact that my CE4 site does not provide this, I searched this forum and found Tom Owens' and other posts in 2014.
Those posts are too technical for me. I do not use WordPress, or TTG's shared resources, which had been causing problems for me. I just need an obligatory cookie warning with dismiss option to pop up when the cart is opened, or at whatever moment it is that the cookie needs to be placed on the user's computer. Such a friendly popup would need to say that the cookie is needed to serve the cart and that it will be deleted when the browser is closed. Or suchlike.
Is there a simple way to achieve this? I would be able to edit a css or php file in a specific directory if someone can tell me which file(s) and what text I would need to put where. Thanks in advance.
Offline
a pop up is going to require javascript or jQuery conditionally inserted via phplugins
A simple solution is to use the text sidebar in your galleries to place your notice.
If you're using Publisher, you can place the text in the template's sidebar and then just include that template sidebar text when you create your albums.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I would be curious to know how other commercial CE4 users within the EU have dealt with this. It is becoming virtually impossible to open any commercial, insurance, local government or whatever website (other than a purely private site) without the visitor being notified on the home page of the fact that cookies are required for normal operation (or as the case may be) and giving the visitor the option to accept this fact by clicking "I agree" or declining it by "I do not accept this", which is fine, but the website will not work and in fact in many cases will not proceed further than the home page.
This is a huge problem for the small commercial CE4 user, most of whom may not be aware of the requirements or may choose to ignore them until some authority catches up with them. I am keen to be seen by my clients to adhere to legal requirements concerning my website, however small and insignificant the site may be.
So whilst a sidebar is a simple solution, it would be intrusive in so far as it is unnecessarily permanently visible, and takes up real estate too. I have not delved into the legal aspects but if I am not mistaken, I believe such a passive statement does not go far enough and some form of interaction by the site visitor is required. Having had such interaction, the site then operates as normal without the client being bothered any more.
I hope other users will give their ideas/experience and/or solutions.
Offline
It will be interesting to see what others are doing.
I searched around looking at numerous jQuery and javascript solutions. But there are so many that it gets confusing real fast.
The simplest thing I saw was a javascript confirm() function.
http://www.w3schools.com/js/js_popup.asp
But it would have to pop up in every gallery. Plus I don't know that it prevents the cart from working if the user doesn't agree.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I like things as simple as possible so will work on this; thanks for the link, which is really useful. I am not going to try to stop the cart working; the main thing is to wake people up to the fact that that cookies are going to be used, and at least one of those w3schools scripts would appear to be just what is needed for now. Thanks, Rod.
Offline
The cart JS has its own hooks mechanism that we had previously used to adapt the code for various types of galleries, in particular Highslide. This is handled via a file within your template or gallery at lib/js/ttgcart.hooks.js. This is a good spot to add page functionality.
I've written a bit of code that pops up an alert when the customer clicks on a buy button. If the customer clicks 'cancel' then the page reloads. This isn't particularly graceful but the cart hooks don't provide a mechanism to prevent further actions.
The extra code includes two functions to handle cookies so that the browser can remember that a customer has allowed cookies, and code within the ttgCart.pre_open_modal function. ttgCart.post_populate_buy_buttons would be a more ideal location, except that the use of page reloading as an exit mechanism would continually bombard the user with the popup until choosing 'ok'.
To use this code, copy and paste it into lib/js/ttgcart.hooks.js in your gallery or template. You may want to change the message.
/*
Functions do not need to exist here - jquery.ttgcart.js checks for functions before trying to call them.
However this file should exist, as the browser will get a 404 otherwise.
*/
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
if ("ttgCart" in window) {
ttgCart.post_populate_buy_buttons = function() {}
ttgCart.post_get_pricing = function() {}
ttgCart.pre_open_modal = function() {
var message = "We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies from this website. \n\nIf you would like to change your preferences you may do so by following the instructions at http://www.aboutcookies.org/Default.aspx?page=1";
var cookiesAllowed = getCookie("cookiesAllowed");
if (cookiesAllowed == undefined || !cookiesAllowed) {
if (confirm(message)) {
setCookie("cookiesAllowed", 1, 7);
} else {
location.reload();
}
}
}
ttgCart.post_open_modal = function() {}
ttgCart.add_success = function() {}
ttgCart.add_error = function() {}
ttgCart.post_cancel_modal = function() {}
ttgCart.pre_load_widget = function() {}
ttgCart.post_load_widget = function() {}
ttgCart.post_click_add_button = function() {}
}
Offline
Somewhere in the back of my mental closet, I've been meaning to write a tutorial on how to implement an EU cookie warning via PHPlugins. If that every actually happens, it will probably use this:
https://github.com/creativeaura/eu-cookie-opt-in
Offline
That somehow needs to integrate with the cart functionality to disable it if the user opts out.
Offline
I have implemented Ben's script in my gallery template's ttgcart.hooks.js and it generates the desired message in a modest way as soon as the viewer clicks on the cart icon on a thumbnail. It goes away nicely if one accepts cookies. The page reloads as expected if one clicks on "cancel".
However by following the moment of cookie placement in Firefox I have now noticed the new cookie appearing at an earlier stage than when using the cart, namely even when the gallery template is first opened or perhaps even on entering the site (I use Stage). I am fairly sure about this since I have removed the cookie from the folder before closing and restarting Firefox. I tried to follow the cookie in IE but could not even find it in the list of cookies, so confess ignorance as far as IE is concerned. The opt-in message works anyway in the same way whether I view the page in IE or in Firefox.
I think the most user-friendly interface would be the moment at which the user clicks the (in my case) "Enter site" button bottom right of the home Stage flip page. This is then the moment at which, at least on my site, the user first accesses the contents of the /galleries/ folder. A cookie opt-in at this moment would appear to me the least intrusive alert for the user before he gets down to business in the site proper.
My question is therefore: can I use a similar hook in some other .js file to provoke the cookie opt-in message into action at an earlier stage?
Offline
Hi Martin,
I'm not aware of a more general way of doing this that would interrupt the page loading prior to TTG pages creating a session (and hence creating a cookie). You could say that the solution I provided works in 'the spirit' of the law. The cookie may exist but it's not matched to any data.
A robust solution would be to interrupt the page flow before any TTG PHP pages have even begun to load. Thinking aloud here, one idea I had:
1) Create an .htaccess file that checks for the existence of a cookie (call it the 'AllowCookies' cookie)
2) If the cookie doesn't exist, redirect to a new page that prompts the user to proceed with cookies or not
3) If proceeding, add the AllowCookies cookie and take the user back to the page at 1)
4) The .htaccess would see that the AllowCookies cookie is there and not interrupt the flow to the originally requested page
The .htaccess could be added to whichever directory makes sense as an entry point, for example galleries/ in your case.
Such a system would consist of two files:
An .htaccess file
A php file to prompt the customer and redirect to the originally requested page or not
These two files would not interfere with any TTG code.
Offline
Pages: 1