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: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Get Poster Id in Template

Post by LuigiMdg »

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 Kailey on Wed Jan 24, 2018 1:45 am, edited 1 time in total.
Reason: Moved to phpBB Custom Coding.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Get Poster Id in Template

Post by Kailey »

By default, viewtopic will have many poster ids. What is it you're trying to actually accomplish?
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
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

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
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Get Poster Id in Template

Post by Kailey »

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 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
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

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
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Get Poster Id in Template

Post by warmweer »

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?
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

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
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Get Poster Id in Template

Post by Kailey »

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 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
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

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: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

Nobody can help me? :(
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Get Poster Id in Template

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

I want just 1 variable..!
User avatar
LuigiMdg
Registered User
Posts: 143
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Get Poster Id in Template

Post by LuigiMdg »

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”