Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Ice_Drake - toukokuu 26, 2014, 05:57:09 AP

Otsikko: Boolean Check for Post Topic (not reply)
Kirjoitti: Ice_Drake - toukokuu 26, 2014, 05:57:09 AP
Hi, I am looking for a way to check if a post is the topic (not its replies). I have no clue where or how to write up such boolean condition. I need to use it in Display.template.php for SMF 2.0.7. Thanks in advance.
Otsikko: Re: Boolean Check for Post Topic (not reply)
Kirjoitti: margarett - toukokuu 26, 2014, 07:11:58 AP
Like this:

while ($message = $context['get_message']())
{

if ($message['id'] == $context['topic_first_message'])
echo 'YAY, TOPIC FIRST MESSAGE!!!';

Example result attached ;)
Otsikko: Re: Boolean Check for Post Topic (not reply)
Kirjoitti: Arantor - toukokuu 26, 2014, 11:09:13 AP
I'd sort of wonder what the use here is for this because that test may not be enough...
Otsikko: Re: Boolean Check for Post Topic (not reply)
Kirjoitti: Ice_Drake - toukokuu 27, 2014, 03:20:29 AP
Lainaus käyttäjältä: Arantor - toukokuu 26, 2014, 11:09:13 AP
I'd sort of wonder what the use here is for this because that test may not be enough...

No, it is good enough. I have modified a mod that you can like or unlike a post to allow hate or unhate a post. I just need to let users to like or hate only the topic post, not just all posts including the replies. It was just what I needed. Thanks!
Otsikko: Re: Boolean Check for Post Topic (not reply)
Kirjoitti: Arantor - toukokuu 27, 2014, 08:09:25 AP
Aside from the fact it doesn't actually enforce it and would be quite possible to hate any post...