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.

Collapsible categories

Go down

In progress Collapsible categories

Post by Lizlee on Fri Jan 24, 2014 10:59 pm

Hi guys, 
I want collapsible categories for my forum and I used this javascript code for it.
It works but only by the last category. I dont know if I have to edit the code or have to do something else. I hope you guys will know the answer (:


$(function () {
    var b = $(".secondarytitle").get();
    for (i = 0; i < b.length; i++) {
        var a = b[i].parentNode.parentNode.childNodes;
        $(b[i].parentNode).click(function () {
            for (i = 1; i < a.length; i++) "none" == a[i].style.display ? a[i].style.display = "" : a[i].style.display = "none", my_setcookie( + "_forums", a[1].style.display, !1)
        if (my_getcookie( + "_forums")) for (i = 1; i < a.length; i++) a[i].style.display = my_getcookie( + "_forums")


Posts : 56
Reputation : 2
Language : Dutch,English

Back to top Go down

In progress Re: Collapsible categories

Post by Ange Tuteur on Sat Jan 25, 2014 2:15 am

Hello Lizlee,

See if this code works :
Administration Panel > Modules > Javascript codes managment

Placement : in the homepage

            $('#content-container .secondarytitle').parent().append('<span class="toggles"><img src=""/></span>');
            var heads = $('#content-container .secondarytitle').parent();
            for(var i=0;i<heads.length;i++){
            class: 'parent'
            var cookie = ReadCookie('catTog').split(',');
            for(var j=0;j<cookie.length;j++){
            $('.toggles').on('click',function() {
            var g = $(this).closest('.parent').nextAll('tr').css('display');
            cookieList = ReadCookie('catTog');
            if(g == "table-row") {
            var cid= $(this).closest('.parent').attr('id');
            } else {
            var newCookie=[],
            a= $('.parent').nextAll('tr').filter(":hidden"),
            c = $.map(a,function(n,i){
            return "#"+$(a).closest('.parent').attr('id');
            newCookie= c.join(',');
                SetCookie('catTog',newCookie, 100);
            function SetCookie(cookieName,cookieValue,nDays) {
            var today = new Date();
            var expire = new Date();
            if (nDays===null || nDays===0) nDays=1;
            expire.setTime(today.getTime() + 3600000*24*nDays);
            document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
            function ReadCookie(cookieName) {
            var theCookie=""+document.cookie;
            var ind=theCookie.indexOf(cookieName+"=");
            if (ind===-1 || cookieName==="") return "";
            var ind1=theCookie.indexOf(";",ind);
            if (ind1==-1) ind1=theCookie.length;
            return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
            function KillCookie(cookieName){SetCookie(cookieName,"",-1);}

Then add this CSS :
Display > Colors > CSS stylesheet
   .toggles {
        position: absolute;
        right: 15px;
        top: 9px;
Ange Tuteur

Male Posts : 13194
Reputation : 2907
Language : EN10, FR5, JA5
Location : Macungie, PA

Back to top Go down

In progress Re: Collapsible categories

Post by Lizlee on Sat Jan 25, 2014 9:07 pm

Well, it works but not exactly how I wanted it to because right now there are these images at the corners of my categories where you have to click at so it will collapse. But I want that if a click at any place of the category that it will collapse (not the forums underneath it, only the category)

Hope you understand what I mean


Posts : 56
Reputation : 2
Language : Dutch,English

Back to top Go down

Back to top

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