Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Biology Forums on October 26, 2014, 02:26:38 PM

Title: Is it possible to execute this code in display.template.php
Post by: Biology Forums on October 26, 2014, 02:26:38 PM
For SMF 1,

If the last poster ID of this topic is equal to the ID of the logged in member
Echo'';


This is going somewhere in display.template.php.

Was wondering if SMF keeps information about the poster of the last message added. If possible, could someone write it out for me.
Title: Re: Is it possible to execute this code in display.template.php
Post by: margarett on October 26, 2014, 03:11:13 PM
You aren't making much sense :P

The code you asked is perfectly possible to be made in 2.0
But then you mention details about last message added.

Can you rephrase to specify what you need? ;)
Title: Re: Is it possible to execute this code in display.template.php
Post by: Biology Forums on October 26, 2014, 03:21:00 PM
If the member that posted last in this topic equals the ID of the member who's logged in.
Title: Re: Is it possible to execute this code in display.template.php
Post by: margarett on October 26, 2014, 04:02:23 PM
I'm sorry, it is clear, I misread.

I'm not sure and I'm not on the computer right now, but you can print_r $topic (or is it $context['topic'] ?) and you can see the current information. When I get to the computer I can check it for you ;)
Title: Re: Is it possible to execute this code in display.template.php
Post by: Biology Forums on October 26, 2014, 05:17:35 PM
Thanks, looking forward to your response.
Title: Re: Is it possible to execute this code in display.template.php
Post by: Pipke on October 26, 2014, 07:10:02 PM
ok here you go.. in Display.template.php
Find:

// Show information about the poster of this message.


Replace with:

// Show information about the poster of this message.
$lastid = $message['member']['id'];


next do

Find:

echo '<br />';


Replace with:

echo '<br />';

if ($context['user']['id'] == $lastid)
echo'<p><b>The last poster in this topic is the person who is logged in now!</b></p>';


save, upload and your good to go, before changes make backup of the file.
Title: Re: Is it possible to execute this code in display.template.php
Post by: margarett on October 26, 2014, 07:43:46 PM
That's not entirely true... That only works if the last post is on the page currently being viewed.

Looking at it now, there is no such information being extracted by default. You get the ID of the last post but not its author.
If you need to do that, an extra query is required ;)
Title: Re: Is it possible to execute this code in display.template.php
Post by: Arantor on October 26, 2014, 07:46:47 PM
And you couldn't add, say, t.ID_MEMBER_UPDATED to the query early in Display.php where it already fetches t.id_MEMBER_STARTED and then check $topicinfo['ID_MEMBER_UPDATED']

We need an innocent-whistle smiley.
Title: Re: Is it possible to execute this code in display.template.php
Post by: Biology Forums on October 26, 2014, 10:57:26 PM
Thanks fellas, I think I'll try what Arantor suggested.