It is currently 19 Feb 2018, 14:19

Anything Goesphpbb 3.2: How to give the first responder/replier a custom badge hack (Showcase | Slideshow)

Anything, almost anything at all
(even advertisement if it's decent, spammers will be banned)
Post Reply
User avatar
tim

Administrator
View: Showcase | Slideshow
Topic Posts: 2/3
Posts: 2157
Joined: 26 Sep 2016, 00:16
Cash on hand: 7,894.01 GLP
Bank: 51,356.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1196
x 256
Contact:
Canada

phpbb 3.2: How to give the first responder/replier a custom badge hack

Post#1 by tim » 18 Jun 2017, 14:39


in phpbb 3.2, I wanted to give the first person who replies to a topic (that isn't a topic author) a "Topic 1st Responder badge" (just a custom image).
I looked around and there doesn't seem to be an extension for this already.
So I hacked it.
Here's how i did it.
in your viewtopic.php
find code

Code: Select all

$first_unread = $post_unread = false;
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
and add before

Code: Select all

// first responder hack begins
$sql = 'SELECT IFNULL(p.poster_id,0) as id FROM phpbbsf_posts p 
		WHERE p.topic_id = ' . $topic_id .
	   ' AND p.poster_id != ' . $topic_data['topic_poster'] .
	   ' ORDER BY p.post_id ASC
		LIMIT 1';
$myresult = $db->sql_query($sql);
while ($first_responder = $db->sql_fetchrow($myresult))
{
	$first_responder_id = $first_responder['id'];
}
$db->sql_freeresult($myresult);
// first responder hack ends
and then find code

Code: Select all

'S_TOPIC_POSTER'	=> ($topic_data['topic_poster'] == $poster_id) ? true : false,
add after

Code: Select all

'S_FIRST_RESPONDER' => ($first_responder_id == $poster_id) ? true : false, // first responder hack
Then now in my styles/prosilver/template/viewtopic_body.html
I just add this code
before displaying rank (after displaying names)

Code: Select all

<!-- first responder hack Tin Tran -->
<!-- IF postrow.S_FIRST_RESPONDER --><div><img src="/images/ranks/First_Responder.png"/></div><!-- ENDIF -->
Where First_Responder.png is just my own created custom image that says "Topic 1st Responder"
0 x



aka Tin
Image gimplearn.net                                              

Registered members enjoy ads-free content
User avatar
tim

Administrator
View: Showcase | Slideshow
Topic Posts: 2/3
Posts: 2157
Joined: 26 Sep 2016, 00:16
Cash on hand: 7,894.01 GLP
Bank: 51,356.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1196
x 256
Contact:
Canada

Post#2 by tim » 18 Jun 2017, 17:03


If you want to go a little more and want to badge your 2nd responder and 3rd responder you can use the below code in similar places as above.
then add IF checks in you viewtopic_body.html to output whatever custom image.

Code: Select all

// first responder hack begins
$first_responder_id = 0;
$second_reponder_id = 0;
$third_responder_id = 0;
$sql = 'SELECT IFNULL(p.poster_id,0) as id FROM phpbbsf_posts p 
		WHERE p.topic_id = ' . $topic_id .
	   ' AND p.poster_id != ' . $topic_data['topic_poster'] .
	   ' ORDER BY p.post_id ASC
		LIMIT 1';
$myresult = $db->sql_query($sql);
while ($first_responder = $db->sql_fetchrow($myresult))
{
	$first_responder_id = $first_responder['id'];
	if ($first_responder_id == '') {$first_responder_id = '0';}
}
$db->sql_freeresult($myresult);
// second responder
$sql = 'SELECT IFNULL(p.poster_id,0) as id FROM phpbbsf_posts p 
		WHERE p.topic_id = ' . $topic_id .
	   ' AND p.poster_id != ' . $topic_data['topic_poster'] .
	   ' AND p.poster_id != 0' . $first_responder_id .
	   ' ORDER BY p.post_id ASC
		LIMIT 1';
$myresult = $db->sql_query($sql);
while ($second_responder = $db->sql_fetchrow($myresult))
{
	$second_responder_id = $second_responder['id'];
	if ($second_responder_id == '') {$second_responder_id = '0';}
}
$db->sql_freeresult($myresult);
// third responder
$sql = 'SELECT IFNULL(p.poster_id,0) as id FROM phpbbsf_posts p 
		WHERE p.topic_id = ' . $topic_id .
	   ' AND p.poster_id != ' . $topic_data['topic_poster'] .
	   ' AND p.poster_id != 0' . $first_responder_id .
	   ' AND p.poster_id != 0' . $second_responder_id .
	   ' ORDER BY p.post_id ASC
		LIMIT 1';
$myresult = $db->sql_query($sql);
while ($third_responder = $db->sql_fetchrow($myresult))
{
	$third_responder_id = $third_responder['id'];
	if ($third_responder_id == '') {$third_responder_id = '0';}
}
$db->sql_freeresult($myresult);

// responder hack ends
and

Code: Select all

'S_FIRST_RESPONDER' => ($first_responder_id == $poster_id) ? true : false, // first responder hack
'S_SECOND_RESPONDER' => ($second_responder_id == $poster_id) ? true : false, // second responder hack
'S_THIRD_RESPONDER' => ($third_responder_id == $poster_id) ? true : false, // third responder hack
0 x



aka Tin
Image gimplearn.net                                              

User avatar
Issabella
Script Tester
View: Showcase | Slideshow
Topic Posts: 1/3
Posts: 1962
Joined: 19 Jan 2017, 11:42
Cash on hand: 17,162.78 GLP
Gender: Gal
Operating System: Windows
x 231
x 505
Spain

Post#3 by Issabella » 18 Jun 2017, 18:04


This is very innovative Tin, you are always thinking of doing this forum with plenty of options for all of us. Thanks. :thumbsup:
1 x



Issabella

Post Reply

Last 20 Members Who Visited This Topic

User avatar Pat625 (3), User avatar tim (21), User avatar nateart (1), User avatar RJKD (1), User avatar Issabella (3)

  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments Only) •
1: gnerd
2: Issabella
3: Pat625
4: Ella
5: PhotoMaster
6: animicule
7: trandoductin

Who is online

Users browsing this forum: No registered users and 1 guest