Frustration of the day: Adding the "collapsed" class to just one forum on the index.

Support for PhpBB3.
Post here to get help with any phpBB3 related issue
Forum rules
In order the get any support, you will have to do following:
1. Use a describing title!
2. Describe your problem and what happened when the problem occured
3. Tell us what version of phpBB3 you are currently using.
If not your topic may be ignored or locked!

Frustration of the day: Adding the "collapsed" class to just one forum on the index.

Post by pxdetroit »

.
I wonder if anyone has an idea for this.

Are y'all familiar with the "collapsable forum categories" ext? (Of course you are, it's an official phpbb ext.) Anyway, I'm trying to rig it up. :D

What I want to happen is to have just one particular category (f_id) to be closed as the default. People have been asking for that feature for years and the official support answer is "you can't without changing the functionality" blah, blah, blah.

I've thought about going at it from a couple different ways: Monkeying with the template/css files, of course, or monkeying with the functions. Maybe add the "collapsed" class to that forum id, but exactly where is not clear. Also I noticed that if you collapse a forum, the cookies will remember this. So... what if you could set the cookie to default: collapsed for that f_id?

Well I never did find a solution and I moved on to other things (bugs etc). Now I find myself (AGAIN, on this new website) really wanting a single forum to be collapsed on page-load. So I've been going through every file in the ext, trying to gain insight on what I could possibly change to make this happen.

So far I see a couple opportunities to make this happen.

Complicating the matter is in [forumlist_body.html] all the forums seem to run in an invisible list (you know what I mean) and I can't just go to that one and manually call it to default closed. Somehow I'm going to have to get the code to make the designation based on f_id.

I came across this in [listener.php]:

Code: Select all

	public function show_collapsible_categories($event)
	{
		$fid = 'fid_' . $event['row']['forum_id'];
		$row = isset($event['cat_row']) ? 'cat_row' : 'forum_row';
		$event_row = $event[$row];
		$event_row = array_merge($event_row, array(
			'S_FORUM_HIDDEN'	=> $this->operator->is_collapsed($fid),
			'U_COLLAPSE_URL'	=> $this->operator->get_collapsible_link($fid),
		));
		$event[$row] = $event_row;
	}
}
Maybe this is an opportunity to designate f=27 (for example) to start out as closed. But... yeah I don't know how or what to google to find out.

Then there's this in [main_interface.php]:

Code: Select all

interface main_interface
{
	/**
	 * This method processes AJAX requests for collapsible categories
	 * when a user collapses/expands a category. Collapsed categories
	 * will be stored to the user's db and cookie. Expanded categories
	 * will be removed from the user's db and cookie.
	 *
	 * @param string $forum_id A forum identifier
	 *
	 * @throws \phpbb\exception\http_exception An http exception
	 * @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JSON Response object
	 */
	public function handle($forum_id);
}
Maybe there's room in there to somehow set f-27 to closed.

Finally, I don't even know where to begin with the "cookie" line of opportunity.

I know it's tied to sessions. In this ext they use the term cookie, not session. There's a lot going on in [operator.php] and [operator_interface.php]. I'm not even going to quote any of it because there's too much. But this looks like a great opportunity to somewhere apply the "collapsed" class to "f_id=27."

What exactly is the "collapsed" class? A search of the entire phpbb folder yields a lot of "toggle" results but IDK if that's for the nav tabs. Searches for "class" inside the ext folder yields a lot of results but not what I expected. Very similar to the above functions.

Anyway.... this is my "frustration" of the moment.

If anyone has ideas I'd love to hear them. I'd like to reciprocate of you have any bugs that need fresh eyes. I don't think I'm as skilled as you all are but I've tinkered around A LOT and I'm willing to try.

Thanks

Re: Frustration of the day: Adding the "collapsed" class to just one forum on the index.

Post by Stoker »

Dont know how to solve it.
But this is the guide how to ADD it to extensions: https://phpbb-extensions.github.io/coll ... /v2xx.html
Maybe you can learn something by that?


BTW, i dont get why you want to do this or why users just cant collapse it?

Re: Frustration of the day: Adding the "collapsed" class to just one forum on the index.

Post by pxdetroit »

I've been all over that guide. I see a couple opportunities to tell the code to do something about f=27 but I'm not good enough with js to make it happen. The reason is, I have a very long category. With it open it doubles the page length, but it's sort of important that it be on the index page. For the last one, people are dumb. If my project takes off there will be a lot of randos on there who've never used anything but a phone. By the time they get done scrolling to the moon they'll be overwhelmed and maybe just leave. I want them engaged. I want them to pick from one of the choices, preferably in the top section.

Re: Frustration of the day: Adding the "collapsed" class to just one forum on the index.

Post by Stoker »

If you want it collapsed by default, it cant be that important?
Move it to the bottom of the forum index or put it inside a category.

The collapsed choices are stored in the DB->users table.
So you can run a sql querie in phpmyadmin to make it collapse for all users.
Downside is that its only for current users. New users wont have it collapsed.

Dont ask me about the querie :D
But remember to backup if you want to play with this.

Another option is to play with the migrations/installer so that specific choice is saved by default in the users table. This would work both for existing and new users.
But you need to create a new, or edit existing and then install the extension again.
If you can figure that one out, it would be the best solution.