Modify display forums row

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Modify display forums row

Post by Kailey »

I'm having some trouble with an extension I'm working on. Basically, if a post is marked as an answer, then the topic has a green check next to the topic title. The problem is on the index page - extension works fine if the forum is by itself, but once you add a subforum to it, it stops working. Current code is as follows:

Code: Select all

public function display_forums_modify_forum_rows($event)
{
	$forum_rows = $event['forum_rows'];
	$parent_id = $event['parent_id'];
	$row = $event['row'];

	$forum_rows[$parent_id]['answer_post_id'] = $row['answer_post_id'];

	$event['forum_rows'] = $forum_rows;
}
The code above also has another function (display_forums_modify_template_vars) that assigns the check to the forumrow. The template function is not the issue as I've verified. You can see the problem below the first forum has a subforum while the second forum doesn't. Both have topic replies marked as answers. Any help would be appreciated.

Image
Last edited by Kailey on Sun Nov 19, 2017 11:40 pm, edited 1 time in total.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Modify display forums row

Post by mrgoldy »

The first thing that comes to my mind, looking over forumlist_body, is that it might have to do with the first row instead of subforums or not?
eg: <!-- IF forumrow.S_IS_CAT or forumrow.S_FIRST_ROW or forumrow.S_NO_CAT -->

Forumlist has a different display for that.
Last edited by mrgoldy on Mon Nov 20, 2017 7:24 pm, edited 1 time in total.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Modify display forums row

Post by Kailey »

The problem isn't the template - it's the PHP code I posted. I can verify this by changing $forum_rows[$parent_id]['answer_post_id'] = $row['answer_post_id']; to $forum_rows[$row['forum_id']]['answer_post_id'] = $row['answer_post_id']; and it shows, but for all topics regardless if the topic has been answered or not.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Modify display forums row

Post by Kailey »

Bump?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Modify display forums row

Post by Kailey »

Any help please?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Modify display forums row

Post by 3Di »

I cloned your repo and modified your ext.php to install on my 3.2.1 test-bed (btw better to check for constants.php there since you are relying on future MCP's template events you did self-create 2 PRs for) ;)

I can't reproduce your issue as you can see here in my grabs I posted below, everything seems to work as it should.
https://prnt.sc/hd4l6b
https://prnt.sc/hd4ma1

You sure you selected "use best answer" creating the subforum? If not and then it works for you as well then you should consider to add some check into your above code - which seems to me a bit "poor" at a first glance (missing checks and conditions?), so to speak. More if you tell me what ever I could do to further test your ext.

On a side note, the FA icons looks like a "topic solved" icon, maybe because in this site it is used like that and I am used to - instead at stackoverflow means the the best answer.. in fact. Tastes.
May I suggest to change it maybe with a trophy of any sort?

Last but not least, IMHO that icon should directly lead to the relative post which has been marked as the best answer, if clicked. Along with an ALT/TITLE attribute, that would be an excellent enhancement.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Modify display forums row

Post by Kailey »

3Di wrote: Tue Nov 21, 2017 2:04 am (btw better to check for constants.php there since you are relying on future MCP's template events you did self-create 2 PRs for) ;)
Out of curiosity, why?
3Di wrote: Tue Nov 21, 2017 2:04 am I can't reproduce your issue as you can see here in my grabs I posted below, everything seems to work as it should.
https://prnt.sc/hd4l6b
https://prnt.sc/hd4ma1

You sure you selected "use best answer" creating the subforum?
You can see the problem here. New install with the repo from GitHub. Your third forum, You first sub-forum and Your fourth forum all have bestanswer enabled. Your third forum and Your fourth forum both have topics with answers selected. The check appears for Your fourth forum but not Your third forum (on the index page). If I move a topic to Your first sub-forum, then the check shows (which is why your test was fine, you had a topic in your sub-forum). So for some reason it's not picking up the ones in Your third forum - it's only looking at the sub-forum.
3Di wrote: Tue Nov 21, 2017 2:04 am your above code - which seems to me a bit "poor" at a first glance (missing checks and conditions?), so to speak.
The code is not finished. I haven't added checks and conditions yet. This is all in BETA. ;)
3Di wrote: Tue Nov 21, 2017 2:04 am On a side note, the FA icons looks like a "topic solved" icon, maybe because in this site it is used like that and I am used to - instead at stackoverflow means the the best answer.. in fact. Tastes.
May I suggest to change it maybe with a trophy of any sort?

Last but not least, IMHO that icon should directly lead to the relative post which has been marked as the best answer, if clicked. Along with an ALT/TITLE attribute, that would be an excellent enhancement.
Can you post these suggestions in the development topic please? I'd like to keep this topic strictly related to the issue I'm having.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Modify display forums row

Post by david63 »

kinerity wrote: Tue Nov 21, 2017 2:28 pm Out of curiosity, why?
Constants is always reporting the version in the files, config (which from the comment I assume is what you are checking) can be wrong if the database update has not been run, or has not fully updated.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Modify display forums row

Post by 3Di »

^^ this ^^ :)
kinerity wrote: Tue Nov 21, 2017 2:28 pm
3Di wrote: Tue Nov 21, 2017 2:04 am your above code - which seems to me a bit "poor" at a first glance (missing checks and conditions?), so to speak.
The code is not finished. I haven't added checks and conditions yet. This is all in BETA. ;)
I know what you mean but without checks and conditionals won't work, that's the meaning. ;)

Here's the function, tested a bit.
If any glitch you know from where to start.

Code: Select all

	public function display_forums_modify_forum_rows($event)
	{
		$forum_rows = $event['forum_rows'];
		$parent_id = $event['parent_id'];
		$row = $event['row'];

		/* Merely suggested by the core code, equal posts time should never happen but hey  */
		if ($row['forum_last_post_time'] >= $forum_rows[$parent_id]['forum_last_post_time'])
		{
			/* Is the forum authed and the related answer_post_id is not null? */
			if ( $row['enable_answer'] && !($forum_rows[$parent_id]['answer_post_id'] === false) )
			{
				$forum_rows[$parent_id]['answer_post_id'] = $row['answer_post_id'];
			}
		}

		$event['forum_rows'] = $forum_rows;
	}

In your migration you did cast the starting value to INT zero for
'answer_post_id' => array('UINT', 0),
I am checking against 'false' because that bit in the array of the event it is a string
["answer_post_id"] => string(1) "0".
kinerity wrote: Tue Nov 21, 2017 2:28 pm
3Di wrote: Tue Nov 21, 2017 2:04 am On a side note, the FA icons looks like a "topic solved" icon, maybe because in this site it is used like that and I am used to - instead at stackoverflow means the the best answer.. in fact. Tastes.
May I suggest to change it maybe with a trophy of any sort?

Last but not least, IMHO that icon should directly lead to the relative post which has been marked as the best answer, if clicked. Along with an ALT/TITLE attribute, that would be an excellent enhancement.
Can you post these suggestions in the development topic please? I'd like to keep this topic strictly related to the issue I'm having.
Feel free to open an issue at your repo so to keep track of this, if you like the idea, thanks. :)
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Modify display forums row

Post by Kailey »

That seems to have fixed it! Thank you so much!
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
Post Reply

Return to “Extension Writers Discussion”