Category Toggle - not reading cookies
4 posters
Page 1 of 1
Category Toggle - not reading cookies
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:
within the Homepage message
and:
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?
- 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?
Re: Category Toggle - not reading cookies
Hello,
try to add this code:
in your javascript panel
ACP > Modules > HTML & JAVASCRIPT > Javascript codes management
Friendly,
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,
Re: Category Toggle - not reading cookies
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.
Re: Category Toggle - not reading cookies
Why not ask the author of the script?
http://dion-designs.com/area51/index.php
http://dion-designs.com/area51/index.php
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Similar topics
» Category Toggle
» Category Toggle - No Appearance
» Category Toggle Script
» Category Toggle + & -
» category-toggle
» Category Toggle - No Appearance
» Category Toggle Script
» Category Toggle + & -
» category-toggle
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum