Modify display forums row

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Modify display forums row

Post by kinerity » Fri Nov 17, 2017 6:25 pm

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 kinerity on Sun Nov 19, 2017 11:40 pm, edited 1 time in total.
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
posey
Registered User
Posts: 546
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Modify display forums row

Post by posey » Sat Nov 18, 2017 12:36 am

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 posey on Mon Nov 20, 2017 7:24 pm, edited 1 time in total.
Ultimate Extensions:
Image Ultimate Blog (coming soon)
Image Ultimate Teams

''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Modify display forums row

Post by kinerity » Sat Nov 18, 2017 3:53 am

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.
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Modify display forums row

Post by kinerity » Sat Nov 18, 2017 6:44 pm

Bump?
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Modify display forums row

Post by kinerity » Sun Nov 19, 2017 8:45 pm

Any help please?
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
3Di
Registered User
Posts: 11880
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Modify display forums row

Post by 3Di » Tue Nov 21, 2017 2:04 am

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.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Modify display forums row

Post by kinerity » Tue Nov 21, 2017 2:28 pm

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.
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
david63
Jr. Extension Validator
Posts: 13199
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Modify display forums row

Post by david63 » Tue Nov 21, 2017 3:48 pm

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!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
3Di
Registered User
Posts: 11880
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Modify display forums row

Post by 3Di » Wed Nov 22, 2017 1:03 am

^^ 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. :)
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Modify display forums row

Post by kinerity » Wed Nov 22, 2017 11:29 am

That seems to have fixed it! Thank you so much!
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: Blitze and 12 guests

cron