Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Show similar threads below first post
charafweb Offline
Junior Member
**
Posts: 12
Joined: Jan 2013
Post: #1
Show similar threads below first post
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:
1
2
3
4
5
6
<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)

PHP Code:
global $similarthreads;


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


la-fac.net
(This post was last modified: 02-27-2013 09:36 PM by charafweb.)
02-27-2013 09:32 PM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #2
RE: Show similar threads below first post
Instead of core editing you can use {$GLOBALS['similarthreads']}, also note that it will only show if there are any threads to be shown.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
02-28-2013 08:08 AM
Visit this user's website Find all posts by this user Quote this message in a reply
charafweb Offline
Junior Member
**
Posts: 12
Joined: Jan 2013
Post: #3
RE: Show similar threads below first post
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

la-fac.net
(This post was last modified: 02-28-2013 09:22 AM by charafweb.)
02-28-2013 09:18 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Show similar threads below first post
$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

HTML Code
<!-- SIMILAR_POSTS -->

and use the following in the showthread template

Code:
<?=str_replace('<!-- SIMILAR_POSTS -->', $similar_posts, $posts)?>

instead of just using {$posts}


My Blog
02-28-2013 09:43 AM
Find all posts by this user Quote this message in a reply
charafweb Offline
Junior Member
**
Posts: 12
Joined: Jan 2013
Post: #5
RE: Show similar threads below first post
Marvellous Yumi Yipi. It's working like a charm. I know you will have a solution for this, this is why I came here Yes

recap:

I placed this code in postbit template:

PHP Code:
<if $postcounter == "1" then>
    <!-- SIMILAR_THREADS -->
</if> 


And then I replaced:

PHP Code:
{$posts}


in showthread template

with this:

PHP Code:
<?=str_replace('<!-- SIMILAR_THREADS -->', $similarthreads, $posts)?>


Thanks Love


la-fac.net
(This post was last modified: 02-28-2013 07:12 PM by charafweb.)
02-28-2013 10:41 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #6
RE: Show similar threads below first post
You may want to change:

Code:
<if $postcounter == "1" then>


With:

Code:
<if $GLOBALS['thread']['tid'] && $GLOBALS['thread']['firstpost'] == $post['pid'] then>


Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
03-01-2013 08:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #7
RE: Show similar threads below first post
^ Is there much of a difference?

My Blog
03-01-2013 10:51 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #8
RE: Show similar threads below first post
Probably not, just sharing what I did learn here, it is what I use since then Tongue

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
(This post was last modified: 03-01-2013 01:37 PM by Sama34.)
03-01-2013 01:37 PM
Visit this user's website Find all posts by this user Quote this message in a reply
charafweb Offline
Junior Member
**
Posts: 12
Joined: Jan 2013
Post: #9
RE: Show similar threads below first post
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.


la-fac.net
03-01-2013 07:23 PM
Find all posts by this user Quote this message in a reply
letsforum Offline
Junior Member
**
Posts: 36
Joined: Sep 2013
Post: #10
RE: Show similar threads below first post
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!!!


Internet marketing and SEO forum - http://letsforum.com
(This post was last modified: 02-10-2014 08:23 AM by letsforum.)
02-10-2014 07:51 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: