Get Poster Id in Template

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Get Poster Id in Template

Post by LuigiMdg » Wed Jan 24, 2018 12:59 am

Hi..
How to get the poster user id in the viewtopic_body.html?
I'm trying to get this by mini PHP script for a simple query, but I'm getting crazy..!
I've readed various documentations and similar topics in this forum, but is too old and not work..!
Please, help me :(
Last edited by kinerity on Wed Jan 24, 2018 1:45 am, edited 1 time in total.
Reason: Moved to phpBB Custom Coding.

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1973
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Get Poster Id in Template

Post by kinerity » Wed Jan 24, 2018 1:03 am

By default, viewtopic will have many poster ids. What is it you're trying to actually accomplish?
Kailey Truscott - Community Team

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Wed Jan 24, 2018 1:39 am

kinerity wrote:
Wed Jan 24, 2018 1:03 am
By default, viewtopic will have many poster ids. What is it you're trying to actually accomplish?
In the statistics of the user (messages,inscription date, etc.), I want to add one more statistic, but external..
I need the poster user id to create a query on my external table that use the user id to identify the records.

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1973
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Get Poster Id in Template

Post by kinerity » Wed Jan 24, 2018 1:45 am

The template variable for each poster in a topic is {postrow.POSTER_ID}. Not sure how you plan on reading that in your script.
Kailey Truscott - Community Team

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Wed Jan 24, 2018 10:23 am

kinerity wrote:
Wed Jan 24, 2018 1:45 am
The template variable for each poster in a topic is {postrow.POSTER_ID}. Not sure how you plan on reading that in your script.
Yes.. But I don't know how to get this value.. I've try with $postrow['POST_AUTHOR_FULL'], with $postrow->POST_AUTHOR_FULL.. But not work..! :(

User avatar
warmweer
Registered User
Posts: 1468
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Get Poster Id in Template

Post by warmweer » Wed Jan 24, 2018 11:49 am

LuigiMdg wrote:
Wed Jan 24, 2018 10:23 am
kinerity wrote:
Wed Jan 24, 2018 1:45 am
The template variable for each poster in a topic is {postrow.POSTER_ID}. Not sure how you plan on reading that in your script.
Yes.. But I don't know how to get this value.. I've try with $postrow['POST_AUTHOR_FULL'], with $postrow->POST_AUTHOR_FULL.. But not work..! :(
Viewtopic_body contains post in a topic, so it's not improbable that there will be many different authors (members). As implied by kinerity you'll have to write some kind of itteration running through each postrow, checking the value you need (either user_id or username (or ... _clean) and when you get a hit, then execute some more code. Also keep in mind that when viewing a topic, you are actually only viewing 1 page (of possibly more depending on the setting of the number of posts per page.

For more precise help, you'll have to explain a little better on what you want to do exactly.
Is it adding an external statistic about a user_id into each postrow in viewtopic_body.html?
A bug is a feature that hasn't made it to the manual (yet)

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Wed Jan 24, 2018 12:00 pm

warmweer wrote:
Wed Jan 24, 2018 11:49 am
Viewtopic_body contains post in a topic, so it's not improbable that there will be many different authors (members). As implied by kinerity you'll have to write some kind of itteration running through each postrow, checking the value you need (either user_id or username (or ... _clean) and when you get a hit, then execute some more code. Also keep in mind that when viewing a topic, you are actually only viewing 1 page (of possibly more depending on the setting of the number of posts per page.

For more precise help, you'll have to explain a little better on what you want to do exactly.
Is it adding an external statistic about a user_id into each postrow in viewtopic_body.html?
Yes..
I've created a game that use the user_id to play and in this game the users use the virtual coins.. I want to show the coins in the user informations in the posts..

Example of table:
phpbb_user id | coins
2 | 597

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1973
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Get Poster Id in Template

Post by kinerity » Wed Jan 24, 2018 1:35 pm

Why not just add the coins field to the USERS_TABLE? Then you could write an extension (take a look at how my Best Answer extension adds the "Answers" field to viewtopic mini profiles).
Kailey Truscott - Community Team

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Wed Jan 24, 2018 3:03 pm

kinerity wrote:
Wed Jan 24, 2018 1:35 pm
Why not just add the coins field to the USERS_TABLE? Then you could write an extension (take a look at how my Best Answer extension adds the "Answers" field to viewtopic mini profiles).
Too busy for such a simple operation..
I should change all the game script..!

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Sun Jan 28, 2018 2:14 am

Nobody can help me? :(

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

Re: Get Poster Id in Template

Post by david63 » Sun Jan 28, 2018 2:59 am

LuigiMdg wrote:
Sun Jan 28, 2018 2:14 am
Nobody can help me? :(
Same as you
LuigiMdg wrote:
Wed Jan 24, 2018 3:03 pm
Too busy for such a simple operation..
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
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Mon Jan 29, 2018 12:07 am

I want just 1 variable..!

User avatar
LuigiMdg
Registered User
Posts: 136
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg » Wed Apr 11, 2018 12:01 am

Solved with this in viewtopic.php on row 1919 :

Code: Select all

	//Inizio, Cerco i FC in base all'id utente
	$sql = "SELECT coins FROM g_giocatori WHERE id = $poster_id";

	$result = $db->sql_query($sql);
	$FC = (int) $db->sql_fetchfield('coins');
	$db->sql_freeresult($result);
	//Fine, Cerco i FC in base all'id utente

	$post_row = array(
		'FC'	=>	($FC > 0) ? $FC : false,.
And this on template (viewtopic_body.php) on row 167:

Code: Select all

				<!-- IF postrow.FC -->
					<dd><strong>FC:</strong> {postrow.FC}<img src='https://www.pronosticiippica.it/images/fanta_ippica/coin_min.png' title='Fanta Coin'></dd>
				<!-- ENDIF -->

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests