Hi there,
How to show Similar threads in
first post only.
I added the following code (as suggested by yaldaram)
below {$post} in the "
showthread" template:
PHP Code:
<div id="posts">
{$posts}
<if ($postcounter - 1) % $mybb->settings['postsperpage'] == "0" then>
{$similarthreads}
</if>
</div>
|
I also added this:
(this is suggested by Dennis Tsang)
to inc/functions_post.php.
And Similar threads table setting is enabled in ACP > Configurations > Showthread Options.
But similar threads not appearing. Any Idea?
Thanks
Instead of core editing you can use {$GLOBALS['similarthreads']}, also note that it will only show if there are any threads to be shown.
Sama34 , thank you for the tip. But I'm sure there are threads to be shown.
I noticed also (when using the code above) that similar threads are shown only in threads with one post (the OP one)
Any idea why?
Thanks
$posts is an aggregation of
all posts, so if you want to stick something in the middle of them, you'd need the postbit template.
However, $similar_threads is only evaluated after posts are generated, so it probably won't work simply placing the variable there. What you may be able to do is place this conditionally in the postbit template
and use the following in the showthread template
Code:
<?=str_replace('<!-- SIMILAR_POSTS -->', $similar_posts, $posts)?>
|
instead of just using {$posts}
Marvellous Yumi
. It's working like a charm. I know you will have a solution for this, this is why I came here
recap:
I placed this code in postbit template:
PHP Code:
<if $postcounter == "1" then>
<!-- SIMILAR_THREADS -->
</if>
|
And then I replaced:
in showthread template
with this:
PHP Code:
<?=str_replace('<!-- SIMILAR_THREADS -->', $similarthreads, $posts)?>
|
Thanks
^ Is there much of a difference?
Probably not, just sharing what I did learn here, it is what I use since then
This:
PHP Code:
<if $GLOBALS['thread']['tid'] && $GLOBALS['thread']['firstpost'] == $post['pid'] then>
|
Is not working when thread has multiple pages.
Anyway thanks both for your support.
Hi could you tell me why it hides all the posts? When I use:
PHP Code:
<?=str_replace('<!-- SIMILAR_THREADS -->', $similarthreads, $posts)?>
|
All the posts are gone!!!