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.

PHPBB2 Toggle Categories - Remembering users choices

Go down

Solved PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Wed Nov 26, 2014 9:08 pm

Hello,

I'm fairly new (aka I literally know nothing :\ ) about Jquery, so what I ask may not even be possible.

Using the tutorial found here: http://help.forumotion.com/t114673-toggle-category-for-phpbb2-forum  I was able to get my forum categories to toggle correctly. However when you navigate away from the page they don't remember they choices when you come back.  I have tried to look into the matter more, but I'm unaware how to "setcookie" and if this is possible with forumotion.

Link to Forum:
http://www.thegalaxycauldronforums.com/forum


Current Code:

Code:
<script type="text/javascript">
$(document).ready(function() {
    $(".slidingDiv").show();
$('.secondarytitle').click(function() {
    $(this).closest('tr').siblings('.slidingDiv').slideToggle();
});
  });

</script>


CSS Part

Code:
<!-- BEGIN catrow --><!-- BEGIN tablehead --><table class="forumline" width="100%" border="0" cellspacing="1" cellpadding="0">
 <tr>
 <th colspan="{catrow.tablehead.INC_SPAN}" nowrap="nowrap" width="100%" style="cursor:pointer;" class="secondarytitle">&nbsp;{catrow.tablehead.L_FORUM} <img src="http://i.imgur.com/G8kFoQQ.png" align="right" >&nbsp;</th>
 <th nowrap="nowrap" width="50">{L_TOPICS}</th>
 <th nowrap="nowrap" width="50">{L_POSTS}</th>
 <th nowrap="nowrap" width="150"><div style="width:150px;">{L_LASTPOST}</div></th>
 </tr>
 <!-- END tablehead -->


Last edited by Lady Galaxia on Sun Nov 30, 2014 2:04 pm; edited 2 times in total

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by SLGray on Wed Nov 26, 2014 10:27 pm

Did you exactly do this - http://help.forumotion.com/t114673-toggle-category-for-phpbb2-forum#751496 ?  You have to modify templates.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 42709
Reputation : 3007
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Thu Nov 27, 2014 11:40 am

My Index_box template was modified already so while it didn't match up with the code that was in the tutorial thread I was able to get it to work.

The Function works right now, aside from not remembering if it was collapsed or expanded.

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on Thu Nov 27, 2014 12:07 pm

// Setting a cookie
$.cookie('myCookie':'myValue');

// Creating cookie with all availabl options
$.cookie('myCookie2', 'myValue2', { expires: 7, path: '/', domain: 'example.com', secure: true });

// Get a cookie
$.cookie('myCookie');

// Delete a cookie
$.cookie('myCookie', null);

i will try to get on my forum in few hours and write a code but it is thanksgiving so no promises
avatar
_Twisted_Mods_
Helper
Helper

Male Posts : 2064
Reputation : 314
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Thu Nov 27, 2014 6:45 pm

Oh that would be the most amazing thing ever!

Obviously please enjoy the holiday ^^

Woot Turkey Day!

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on Thu Nov 27, 2014 8:14 pm

wrong topic... ty slgray


Last edited by _Twisted_Mods_ on Thu Nov 27, 2014 8:36 pm; edited 1 time in total
avatar
_Twisted_Mods_
Helper
Helper

Male Posts : 2064
Reputation : 314
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by SLGray on Thu Nov 27, 2014 8:24 pm

@_Twisted_Mods_ wrote:if that brownish tan color is your thanked color this will work

#000000 < = to black
#ebeadd < the tan color

Code:
$(function() {
    var thankColor = '#ebeadd',
        text = 'Best Answer';
    $('.post[style="background-color:' + thankColor.toLowerCase() + ';"]').prepend('<div id="thanked">' + text + '</div>');
});
I believe you posted this in the wrong topic.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 42709
Reputation : 3007
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on Fri Nov 28, 2014 9:28 am

i couldn't even get that code to work for me but ill try to write something later
avatar
_Twisted_Mods_
Helper
Helper

Male Posts : 2064
Reputation : 314
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on Fri Nov 28, 2014 7:49 pm

Hello Lady Galaxia,

Try this :
Go to Administration Panel > Display > templates > General > index_box Edit

Find :
Code:
<!-- BEGIN catrow --><!-- BEGIN tablehead --><table class="forumline" width="100%" border="0" cellspacing="1" cellpadding="0">

Replace by :
Code:
<!-- BEGIN catrow --><!-- BEGIN tablehead --><table class="forumline category" width="100%" border="0" cellspacing="1" cellpadding="0">

Save and publish. Add

Next add this to your CSS :
Display > Colors > CSS stylesheet
Code:
.headRow, .headRow th { position:relative }
.toggler {
  cursor:pointer;
  color:#FFF;
  font-size:12px;
  font-weight:bold;
  background:rgba(0,0,0,0.3);
  padding:2px 4px;
  border-radius:6px;
  position:absolute;
  right:10px;
  top:5px;
}


Finally go to Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In the homepage
Paste the code below and submit :
Code:
$(function() {
  var t = document.getElementsByTagName('TABLE'), n = 0,i;
  for (i=0; i<t.length; i++) {
    if (/category/.test(t[i].className)) {
      var a = document.createElement('SPAN'), c = document.cookie.split(';'),j;
      
      // create button and set some other data
      a.className = 'toggler close';
      a.innerHTML = '-';
      t[i].id = 'catg_'+n;
      t[i].getElementsByTagName('TR')[0].lastChild.appendChild(a);
      a.parentNode.parentNode.className += ' headRow';
      
      // check cookies to see if a category is hidden
      for (j=0; j<c.length; j++) {
        if (new RegExp(t[i].id+'=hidden').test(c[j])) {
          a.className = a.className.replace(/close/,'open');
          a.innerHTML = '+';
          var r = t[i].getElementsByTagName('TR'),k;
          for (k=0; k<r.length; k++) if (!/headRow/.test(r[k].className)) r[k].style.display = 'none';
        }
      }
      
      // handle state change when the user clicks the button
      a.onclick = function() {
        var r = this.parentNode.parentNode.parentNode.getElementsByTagName('TR'), id = this.parentNode.parentNode.parentNode.parentNode.id, date = new Date(),i;
        date.setTime(date.getTime() + (365*24*60*60*1000));
        
        if (/close/.test(this.className)) {
          this.className = this.className.replace(/close/,'open');
          this.innerHTML = '+';
          for (i=0; i<r.length; i++) if (!/headRow/.test(r[i].className)) r[i].style.display = 'none';
          document.cookie = id+'=hidden; expires='+date.toGMTString()+';';
        } else if (/open/.test(this.className)) {
          this.className = this.className.replace(/open/,'close');
          this.innerHTML = '-';
          for (i=0; i<r.length; i++) if (!/headRow/.test(r[i].className)) r[i].style.display = '';
          document.cookie = id+'=shown; expires='+date.toGMTString()+';';
        }
      };
      n += 1;
    }
  }
});


Last edited by Ange Tuteur on Sun Nov 30, 2014 1:08 pm; edited 1 time in total
avatar
Ange Tuteur
Forumaster

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

https://github.com/SethClydesdale

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on Fri Nov 28, 2014 8:05 pm

tested-- works awsome ange .. i couldnt figure the cookie part out i tried and failed
avatar
_Twisted_Mods_
Helper
Helper

Male Posts : 2064
Reputation : 314
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Sun Nov 30, 2014 12:44 pm

This did not remember my choices I made on either Chrome or Firefox.


The collapsing and Expanding was working perfectly fine before hand, I'm having trouble with clicking on a thread and then returning to the forum index and none of the categories I chose to collapse(hide) are hidden.

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on Sun Nov 30, 2014 1:07 pm

I noticed a mistake in chrome. Replace this CSS :
Code:
.headRow { position:relative }

With this :
Code:
.headRow, .headRow th { position:relative }

Also, I tested on Chrome, Firefox, and IE, and they're remembering what categories were hidden. Do you have any other scripts that are modifying the category ?

Demo here : http://generaltesting.forumotion.com/
avatar
Ange Tuteur
Forumaster

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

https://github.com/SethClydesdale

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Sun Nov 30, 2014 1:23 pm

I did have other script located in my index_box

Now that I removed this


Code:
<script type="text/javascript">
$(document).ready(function() {
    $(".slidingDiv").show();
$('.secondarytitle').click(function() {
    $(this).closest('tr').siblings('.slidingDiv').slideToggle();
});
  });

</script>

It doesn't work at all in firefox, the +- image it located in the upper right corner, however it's working perfectly on all regards in Chrome. 


Here is where I am testing:

http://gcftester.forumotion.com/forum

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on Sun Nov 30, 2014 1:35 pm

I tested on your forum with Firefox and it seems to be working okay. Are you accepting cookies on firefox, or using a private browsing window ?
avatar
Ange Tuteur
Forumaster

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

https://github.com/SethClydesdale

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Sun Nov 30, 2014 1:42 pm

I'm using a normal window and accept cookies.

Current settings for FF

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on Sun Nov 30, 2014 1:48 pm

If you haven't, try clearing your browser cache/cookies, and then test to see if it works properly.
avatar
Ange Tuteur
Forumaster

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

https://github.com/SethClydesdale

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on Sun Nov 30, 2014 2:01 pm

Updated my browser >.>

It works!  Thank you very much!

Lady Galaxia
Forumember

Posts : 37
Reputation : 1
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by SLGray on Sun Nov 30, 2014 2:19 pm

Topic solved and archived



When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 42709
Reputation : 3007
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Back to top


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