MyBB Community Forums

Full Version: How to display something only in the first post in a thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to display something like an image in the first post of a thread.

I was searching in showthread.php template and found {$first_post}. But where is the actual file linked to {$first_post} so that i can edit it.



Running Mybb 1.8
MyBB system's showthread template by default doesn't has {$first_post} variable.
you may use XThreads plugin to use required code in the first post
a doubt, is it possible to make use of the {$post_number} variable to check whether its the first post (post number 1) and display the content  Huh Huh
Sir, i am using Xthreads. But how to use xthread to edit the first post. I did not understand. Or if it is possible to use {$post_number) variable to display the desired thing. If yes then how.

Sir please help.
this seems to be working....

you need PHP in Templates plugin for this to work....

add a conditional like below after the {$post['message']} in the postbit template....

{$post['message']}
</div>
<if $post_number == 1 then>
<br />
//Content to be displayed
</if> 
Many Many thanks you are awesome. Thanks a lot.

One More thing, i wanted to ask is that is there any way to extract the first image from thread and display in the forumdisplay_threadlist.
just a note:
php in templates plugin should be used only if one has to add php code into templates
template conditionals plugin is preferred for using the conditions
okay Sir. But, if i use php in templates plugin, will it create any problem.
(2015-01-11, 01:34 PM)dimxo Wrote: [ -> ]if i use php in templates plugin, will it create any problem.

Any admins with templates edit access will be able to execute PHP in your forum. Generally, I also recommend Template Conditionals for such simple tasks.

Also, you should rather check $postcounter since it's a plain integer and $post_number is the formatted version of it: https://github.com/mybb/mybb/blob/featur...t.php#L637
Please help. What is the syntax to check forum id. That is i want to display something in threadlist but not of all forums. Like i want to use conditional tag so that it will display in a particular forum.

Thanks in advance