The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Category Toggle - not reading cookies

View previous topic View next topic Go down

Category Toggle - not reading cookies

Post by neuromaniac on April 30th 2012, 11:04 pm

I have a phpBB3 forum here: http://crimson-mist.forumotion.co.uk/forum and I've tried implementing the category toggle from this tutorial: http://help.forumotion.com/t102749-category-toggle. I made sure all the steps were done. I've rechecked the code and made sure the CSS as the right codes. The code works as far as putting the right buttons in the right places and making them contract and expand properly. It creates and writes the cookies correctly as well but it does not read the cookies properly, so whenever I navigate away from the site or refresh it, any contracted categories extract as if no buttons were pressed in. The codes I used are:

Code:
    <script type="text/javascript">
    function toggleLTcategory(cat) {
        var cid=cat.id;
        var button=document.getElementById('b'+cid);
        if (cat.style.display=='none') {
            cat.style.display='block';
            button.className='contract';
            my_setcookie('_' + cid, '', true);
        }
        else {
            cat.style.display='none';
            button.className='expand';
            my_setcookie('_' + cid, '1', true);
        }
    }

    jQuery(function () {
        x=jQuery('.topiclist .header').get();
        for (i=0; i<x.length; i++) {
            x[i].style.position='relative';
            var cid='c'+String(i+1);
            x[i].parentNode.nextSibling.setAttribute('id',cid);
            x[i].parentNode.nextSibling.style.display='block';
            var y='<div id="b'+cid+'" class="contract" onclick="toggleLTcategory(this.parentNode.parentNode.nextSibling);"></div>';
            x[i].innerHTML=x[i].innerHTML+y;
        }

        cookies = document.cookie.split('; ');
        for (i in cookies) {
            if (cookies[i].charAt(0) == '_') {
                cookie = cookies[i].split('=');
                if (cookie[1] == '1') {
                    cid = cookie[0].substring(1);
                    if (document.getElementById(cid)) {toggleLTcategory(cid);}
                }
            }
        }
    });
    </script>

within the Homepage message

and:
Code:

    .expand, .contract {position: absolute; top: 6px; right: 10px; cursor: pointer; width: 9px; height: 9px; background: url(http://illiweb.com/fa/m/tabs_more1.gif);}
    .contract {background: url(http://illiweb.com/fa/m/tabs_less1.gif);}

at the end of my CSS (I have changed the pictures of the buttons though to ones of my own.

Can anyone here tell me if it can be fixed so the cookies are read?

neuromaniac
New Member

Female Posts : 13
Reputation : 3
Language : English, Polish
Location : Orkney Islands

http://crimson-mist.forumotion.co.uk/

Back to top Go down

Re: Category Toggle - not reading cookies

Post by Niko on May 1st 2012, 2:37 pm

Hello,

try to add this code:
Code:
function toggleLTcategory(cat) {
        var cid=cat.id;
        var button=document.getElementById('b'+cid);
        if (cat.style.display=='none') {
            cat.style.display='block';
            button.className='contract';
            my_setcookie('_' + cid, '', true);
        }
        else {
            cat.style.display='none';
            button.className='expand';
            my_setcookie('_' + cid, '1', true);
        }
    }

    jQuery(function () {
        x=jQuery('.topiclist .header').get();
        for (i=0; i<x.length; i++) {
            x[i].style.position='relative';
            var cid='c'+String(i+1);
            x[i].parentNode.nextSibling.setAttribute('id',cid);
            x[i].parentNode.nextSibling.style.display='block';
            var y='<div id="b'+cid+'" class="contract" onclick="toggleLTcategory(this.parentNode.parentNode.nextSibling);"></div>';
            x[i].innerHTML=x[i].innerHTML+y;
        }

        cookies = document.cookie.split('; ');
        for (i in cookies) {
            if (cookies[i].charAt(0) == '_') {
                cookie = cookies[i].split('=');
                if (cookie[1] == '1') {
                    cid = cookie[0].substring(1);
                    if (document.getElementById(cid)) {toggleLTcategory(cid);}
                }
            }
        }
    });

in your javascript panel
ACP > Modules > HTML & JAVASCRIPT > Javascript codes management

Friendly,

Niko
Hyperactive

Male Posts : 2166
Reputation : 93
Language : English, French, Italian, Spanish, Latin

https://www.translationscloud.com/?utm_source=forumotion&utm

Back to top Go down

Re: Category Toggle - not reading cookies

Post by Dark_Code on May 1st 2012, 9:05 pm

I know I'm having the same problem

Dark_Code
Forumember

Male Posts : 91
Reputation : 4
Language : CSS
Location : Modesto

http://csshelp.ipbhost.com/

Back to top Go down

Re: Category Toggle - not reading cookies

Post by neuromaniac on May 1st 2012, 9:52 pm

Niko! wrote:Hello,

try to add this code:
Code:
function toggleLTcategory(cat) {
        var cid=cat.id;
        var button=document.getElementById('b'+cid);
        if (cat.style.display=='none') {
            cat.style.display='block';
            button.className='contract';
            my_setcookie('_' + cid, '', true);
        }
        else {
            cat.style.display='none';
            button.className='expand';
            my_setcookie('_' + cid, '1', true);
        }
    }

    jQuery(function () {
        x=jQuery('.topiclist .header').get();
        for (i=0; i<x.length; i++) {
            x[i].style.position='relative';
            var cid='c'+String(i+1);
            x[i].parentNode.nextSibling.setAttribute('id',cid);
            x[i].parentNode.nextSibling.style.display='block';
            var y='<div id="b'+cid+'" class="contract" onclick="toggleLTcategory(this.parentNode.parentNode.nextSibling);"></div>';
            x[i].innerHTML=x[i].innerHTML+y;
        }

        cookies = document.cookie.split('; ');
        for (i in cookies) {
            if (cookies[i].charAt(0) == '_') {
                cookie = cookies[i].split('=');
                if (cookie[1] == '1') {
                    cid = cookie[0].substring(1);
                    if (document.getElementById(cid)) {toggleLTcategory(cid);}
                }
            }
        }
    });

in your javascript panel
ACP > Modules > HTML & JAVASCRIPT > Javascript codes management

Friendly,

No luck, still the same effect. Cookies get made, changed if I contract the category but navigating away or refreshing causes the categories to go back to their original state regardless of the cookies.

neuromaniac
New Member

Female Posts : 13
Reputation : 3
Language : English, Polish
Location : Orkney Islands

http://crimson-mist.forumotion.co.uk/

Back to top Go down

Re: Category Toggle - not reading cookies

Post by LGforum on May 1st 2012, 9:54 pm

Why not ask the author of the script?
http://dion-designs.com/area51/index.php

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum