The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Category Toggle - not reading cookies

4 posters

Go down

Category Toggle - not reading cookies Empty Category Toggle - not reading cookies

Post by neuromaniac 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: https://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://2img.net/i/fa/m/tabs_more1.gif);}
    .contract {background: url(http://2img.net/i/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?
avatar
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

Category Toggle - not reading cookies Empty Re: Category Toggle - not reading cookies

Post by Niko 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
Niko
Helper
Helper

Male Posts : 3106
Reputation : 244
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

Back to top Go down

Category Toggle - not reading cookies Empty Re: Category Toggle - not reading cookies

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

I know I'm having the same problem
Dark_Code
Dark_Code
Forumember

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

http://csshelp.ipbhost.com/

Back to top Go down

Category Toggle - not reading cookies Empty Re: Category Toggle - not reading cookies

Post by neuromaniac 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.
avatar
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

Category Toggle - not reading cookies Empty Re: Category Toggle - not reading cookies

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

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

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Back to top

- Similar topics

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