MyBB Community Forums

Full Version: Forum to be collapsed by default
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I set the default mode for a forum to be collapsed instead of expanded? In other words, to show like it does when one clicks the toggle on the right hand side of the forum title? I've looked through the javascript files, php, and templates without any luck - I just can't find where to change the code.
(04-11-2017, 08:03 PM)mikemoum Wrote: [ -> ]How do I set the default mode for a forum to be collapsed instead of expanded? In other words, to show like it does when one clicks the toggle on the right hand side of the forum title? I've looked through the javascript files, php, and templates without any luck - I just can't find where to change the code.
A simple google search would've given you the answer.
https://community.mybb.com/thread-49485.html
Thanks for the answer. I find the suggested thread a bit confusing because it's from when mybb used tables instead of "div", and unfortunately the "div" don't have ids.
(04-12-2017, 03:16 AM)mikemoum Wrote: [ -> ]Thanks for the answer. I find the suggested thread a bit confusing because it's from when mybb used tables instead of "div", and unfortunately the "div" don't have ids.

If you want to PM me admin access I'll give it a look
Here's the solution I came up with. I used jQuery.
MyBB.init();

jQuery(document).ready(function(){
	var x = document.getElementsByClassName("accordion-toggle");
	for (var i = 0; i < x.length - 1; i++) {
		x[i].click();
	}
});
Put the code at the very end of general.js after MyBB.init() in the javascripts folder. Here's the html for the toggle button
	<a class="accordion-toggle collapsed" data-toggle="collapse" href="#cat_3" aria-expanded="false"></a>		
	<a class="accordion-toggle collapsed" data-toggle="collapse" href="#cat_3" aria-expanded="false"></a>		


I don't understand where exactly insert this codes.
I finally find the solution!


On the tag tbody, I insered the style= "display: none" and the collapsed seted by default.



<tbody style= "display: none" id="idname_e">



Thanks!