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

View previous topic View next topic Go down

Solved PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on November 27th 2014, 5:08 am

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 November 30th 2014, 10:04 pm; edited 2 times in total

Lady Galaxia
Forumember

Posts : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by SLGray on November 27th 2014, 6:27 am

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.


SLGray
Administrator
Administrator

Male Posts : 35622
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on November 27th 2014, 7:40 pm

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 : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on November 27th 2014, 8: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

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
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 November 28th 2014, 2:45 am

Oh that would be the most amazing thing ever!

Obviously please enjoy the holiday ^^

Woot Turkey Day!

Lady Galaxia
Forumember

Posts : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on November 28th 2014, 4:14 am

wrong topic... ty slgray


Last edited by _Twisted_Mods_ on November 28th 2014, 4:36 am; edited 1 time in total

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
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 November 28th 2014, 4:24 am

@_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.


SLGray
Administrator
Administrator

Male Posts : 35622
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on November 28th 2014, 5:28 pm

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

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
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 November 29th 2014, 3:49 am

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 November 30th 2014, 9:08 pm; edited 1 time in total

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by _Twisted_Mods_ on November 29th 2014, 4:05 am

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

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
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 November 30th 2014, 8: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 : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on November 30th 2014, 9: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/

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on November 30th 2014, 9: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 : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on November 30th 2014, 9: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 ?

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on November 30th 2014, 9:42 pm

I'm using a normal window and accept cookies.

Current settings for FF

Lady Galaxia
Forumember

Posts : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Ange Tuteur on November 30th 2014, 9:48 pm

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

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by Lady Galaxia on November 30th 2014, 10:01 pm

Updated my browser >.>

It works!  Thank you very much!

Lady Galaxia
Forumember

Posts : 34
Reputation : 0
Language : English

http://galaxycauldron.forumotion.com/

Back to top Go down

Solved Re: PHPBB2 Toggle Categories - Remembering users choices

Post by SLGray on November 30th 2014, 10:19 pm

Topic solved and archived



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


SLGray
Administrator
Administrator

Male Posts : 35622
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.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