4

I'm using Joomla! 3.3.6 and Folcomedia - Cookies Alert plugin.

It's a great plugin but in Italy there is a very strict legislation, now. Practically, the activation of third-party cookies (almost all!) is NOT permitted without agreement. So, I added some more changes, blocking ads and social modules if the cookie Folcomedia is not present, for example; and adding a page refresh when the navigator accepts, to load all missing modules.

This is already good but it's more than a week and I'm trying to integrate the agreement to scroll the page. I'm not an expert but if I try with a php test page, it works, but it has no effect inside the plugin.

So, the first question, in my site are loading these jQuery, are they sufficient?

google.load("jquery", "1.6.1");

js/jquery.min.js js/jquery-noconflict.js js/jquery-migrate.min.js js/jquery.cycle.all.js js/jquery.simplemodal.js

If the cookie does not exist, the plugin loads this banner (at the bottom or the top of the page).

if ($type_affichage == 1) { $function_close = 'onclick="CloseCadreAlertCookie(); javascript:ssxl(\'LINK=Consenso%20Cookie\'); window.location.reload(true)"'; } 

        $text_btn_more = '<div class="'. $meme_ligne .' '.$span.' col-sm-6 btn_readmore" style="margin:5px 0;text-align:'.$position_btn_more.'"><a style="'.$couleur_btn_more_style.'color:'.$couleur_texte_btn_more.'" class="btn '.$couleur_btn_more.' '.$taille_btn_more.' read_more" href="'.JRoute::_("index.php?Itemid=".$link_readmore_menu).'#'.$ancre_link_readmore_menu.'">'.$texte_readmore.'</a></div>';
        $text_btn_more_poup = '<div class="'.$span.' col-sm-6 btn_readmore" style="margin:5px 0;text-align:'.$position_btn_more.'"><a style="'.$couleur_btn_more_style.'color:'.$couleur_texte_btn_more.'" class="btn '.$couleur_btn_more.' '.$taille_btn_more.' read_more" onclick="jQuery.magnificPopup.close();" href="'.JRoute::_("index.php?Itemid=".$link_readmore_menu).'#'.$ancre_link_readmore_menu.'">'.$texte_readmore.'</a></div>';
        $text_btn_close = '<div class="'.$meme_ligne.' '.$span.' col-sm-6 btn_close" style="margin:5px 0;text-align:'.$position_btn_close.'"><button '.$function_close.' style="'.$couleur_btn_close_style.'color:'.$couleur_texte_btn_close.'" class="btn '.$couleur_btn_close.' '.$taille_btn_close.' popup-modal-dismiss">'.$texte_close.'</button></div>';

        $text_out ='<div id="cadre_alert_cookies" style="opacity:'.$opacity.';text-align:'.$position_contenu.';'.$position_fixe_cookie.' margin:'.$marge_ext.'px;">';
        $text_out .='<div style="display: inline-block;width: 100%;margin:auto;max-width:'.$taille_cadre.';background-color: '.$fond_couleur.';'.$css_bordure.'">';
        $text_out .='<div style="display: inline-block;padding:'.$marge_int.'px;color: '.$texte_couleur.'"><div class="cadre_texte '.$meme_ligne.'">'.$texte.'</div>';
        $text_out .='<div class="cadre_bouton '.$meme_ligne.'">';

And this script in page:

if ($type_affichage == 1) {

            $script = '<script type="text/javascript">';
            $script .='var name = "fmalertcookies" + "=";';
            $script .='var ca = document.cookie.split(";");';               
            $script .='for(var i=0; i<ca.length; i++) {';
            $script .='var c = ca[i];';
            $script .='while (c.charAt(0)==" ") c = c.substring(1);';       
            $script .='if (c.indexOf(name) == 0){ document.getElementById("cadre_alert_cookies").style.display="none";}';
            $script .='}';          
            $script .='var d = new Date();';
            $script .='d.setTime(d.getTime() + ('.$duree_cookie.'*(24*60*60*1000)));';
            $script .='var expires_cookie = "expires="+d.toUTCString();';
            $script .="function CloseCadreAlertCookie(){document.getElementById('cadre_alert_cookies').style.display='none'; document.cookie='fmalertcookies=true; '+expires_cookie+'; path=/'}";
            $script .="</script>";

            // Position Haut
            if ($position == 0) {
                $buffer = preg_replace('/<body(.*?)>/i', '<body$1>'.$text_out.$script, $buffer);
            }
            // Position Bas
            elseif ($position == 1) {

                $parts = explode('</body>', $buffer);   
                if (sizeof($parts)<2) {
                    return; // il n'y a pas </body> dans la page
                }

                $parts[sizeof($parts)-2] .= $text_out.$script;
                $buffer = implode('</body>', $parts);                           
            }
        }

Have you any suggestions to supplement the closing div and setting the cookie to scroll the page? Thank you.

I do not know if I have given all the necessary information ...

2

You should not load jQuery from google for a simple reason. There is almost 90% chance it will be loaded from system (so better require it from system like this: JHTML::_('jquery.framework')) so you lose both bandwidth and performance. Not to mention possible conflicts. If script you made don't work on Joomla page there is already a huge chance you have conflicts/errors in Java Script. Use a debugger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.