Similar Topics

Modifications for phpBB3. Try the Mods here and share Your own Mods
There is no support here! Only Read Access!
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support
Locked
User avatar
Post Bot
BBCoder II
BBCoder II
Posts: 44
Joined: 04 Mar 2010, 20:53

Similar Topics

Post by Post Bot »

Similar Topics
Written by Tobi - Modified by Xabi and some small changes by Stoker

The Similar Topics for phpBB3 will give you a box with X similar topics at the bottom of each topic.
You can set the count of similar topics you want displayed.


First thing to do is making sure that the topics table is fulltext indexed. Execute this SQL in phpMyadmin:

Code: Select all

ALTER TABLE `phpbb_topics` ADD FULLTEXT (`topic_title`);
Open viewtopic.php
Find:

Code: Select all

page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id);
Add after:

Code: Select all

// Begin Precise Similar Topics
$sql_array = array(
   'SELECT'   => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_first_poster_name, t.topic_first_poster_colour, MATCH (t.topic_title) AGAINST (\'' . $db->sql_escape($topic_data['topic_title']) . '\' ) as score',

   'FROM'      => array(
      TOPICS_TABLE   => 't',
   ),

   'LEFT_JOIN'   => array(
      array(
         'FROM'   =>   array(FORUMS_TABLE   => 'f'),
         'ON'   => 'f.forum_id = t.forum_id'
      )
   ),

   'WHERE'      => "MATCH (t.topic_title) AGAINST ('" . $db->sql_escape($topic_data['topic_title']) . "' ) >= 0.5
      AND t.topic_status <> " . ITEM_MOVED . '
      AND t.topic_time > (UNIX_TIMESTAMP() - 60*60*24*365)
      AND t.topic_id <> ' . (int) $topic_data['topic_id'],

   'GROUP_BY'   => 't.topic_id',

   'ORDER_BY'   => 'score desc',
);
$sql = $db->sql_build_query('SELECT', $sql_array);
if ($result = $db->sql_query_limit($sql, 5))
{
   while($similar = $db->sql_fetchrow($result))
   {
      if ($auth->acl_get('f_read', $similar['forum_id']))
      {
         $similar_forum_url   = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=" . $similar['forum_id']);
         $similar_topic_url   = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $similar['forum_id'] . '&t=' . $similar['topic_id']);

         $template->assign_block_vars('similar', array(
            'TOPIC_TITLE'         => $similar['topic_title'],
			'TOPIC_VIEWS'					=> $similar['topic_views'],
			'TOPIC_REPLIES'					=> $similar['topic_replies'],
			'TOPIC_TIME'                    => $user->format_date($similar['topic_time']),
			'TOPIC_FIRST_POSTER_NAME'		=> $similar['topic_first_poster_name'],
			'TOPIC_FIRST_POSTER_COLOUR'		=> $similar['topic_first_poster_colour'],
            'U_TOPIC'            => $similar_topic_url,
            'U_FORUM'            => $similar_forum_url,
            'FORUM'               => $similar['forum_name'])
         );
      }
   }
}
// End Precise Similar Topics
Open styles/prosilver/template/viewtopic_body.html
Find:

Code: Select all

<!-- INCLUDE jumpbox.html -->
Before add:

Code: Select all

<!-- IF .similar -->
<!-- IF not S_IS_BOT -->
<div class="forabg">
			<div class="inner"><span class="corners-top"><span></span></span>
			<ul class="topiclist">
				<li class="header">
					<dl>
						<dt>{L_SIM_TOP}</dt>
						<dd class="topics">{L_SIM_REP}</dd>
						<dd class="posts">{L_SIM_VIEWS}</dd>
						<dd class="lastpost"><span>{L_SIM_AUTH}</span></dd>
					</dl>
				</li>
			</ul>
<!-- ENDIF -->
			<!-- BEGIN similar -->
			<ul class="topiclist forums">
			<li class="row">
			<dl>				
				<dt><a href="{similar.U_TOPIC}" class="topictitle">{similar.TOPIC_TITLE}</a><br />{L_SIM_PIF} <a href="{similar.U_FORUM}"><strong>{similar.FORUM}</strong></a></dt>
<!-- IF not S_IS_BOT -->
				<dd class="topics">{similar.TOPIC_REPLIES}</dd>
				<dd class="posts">{similar.TOPIC_VIEWS}</dd>
				<dd class="lastpost"><span>{L_SIM_PBY}: <a style="font-weight:bold; color: #{similar.TOPIC_FIRST_POSTER_COLOUR};" href="{ROOT_PATH}memberlist.php?mode=viewprofile&un={similar.TOPIC_FIRST_POSTER_NAME}">{similar.TOPIC_FIRST_POSTER_NAME}</a><br />{similar.TOPIC_TIME}</span></dd>
<!-- ENDIF -->
			</dl>
			</li>
			</ul>
			<!-- END similar -->
<!-- IF not S_IS_BOT -->
			<span class="corners-bottom"><span></span></span></div>
</div>
<!-- ENDIF -->
<!-- ENDIF -->
Open language/en/viewtopic.php
Find:

Code: Select all

?>
Before add:

Code: Select all

// BEGIN Similar Mod
$lang = array_merge($lang, array(
	'SIM_TOP'			=> 'Similar topics',
	'SIM_REP'			=> 'Replies',
	'SIM_VIEWS'			=> 'Views',
	'SIM_AUTH'			=> 'Author',
	'SIM_PIF'			=> 'Posted in forum:',
	'SIM_PBY'			=> 'Posted by:',
));
// END Similar Mod

FAQ
Q: How do I change the number of similar topics displayed?
A: You can adjust the number in the code you added to viewtopic here:

Code: Select all

if ($result = $db->sql_query_limit($sql, 5))
User avatar
Ashley.S.
BBCoder II
BBCoder II
Posts: 36
Joined: 05 Mar 2010, 12:24
Location: Falmouth, Cornwall, UK
Contact:

Re: Similar Topics

Post by Ashley.S. »

I was about to ask about your Similar topics mod, Thanks for this Stoker
Regards,
-Ashley.S. [ Pluto Hosting Managing Director & ProphpBB Moderator ]
cisco007
BBCoder VI
BBCoder VI
Posts: 1015
Joined: 16 Mar 2010, 18:14
Location: Don't really know!

Re: Similar Topics

Post by cisco007 »

nice one Stoker, this one will come in handy!
Widmo
BBCoder II
BBCoder II
Posts: 11
Joined: 09 Mar 2010, 02:33

Re: Similar Topics

Post by Widmo »

This mode looks like on this site?
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Re: Similar Topics

Post by Stoker »

Almost, I have 8 similar showing, this mod has 5.
But there is oinstructions how to change the similar topic count.
Board rules! No PM support
User avatar
kevinviet
BBCoder III
BBCoder III
Posts: 123
Joined: 06 Mar 2010, 04:52

Re: Similar Topics

Post by kevinviet »

Thanks Stoker, work great
Stark
BBCoder II
BBCoder II
Posts: 18
Joined: 06 Mar 2010, 05:25

Re: Similar Topics

Post by Stark »

Working cool ! thanks for this !
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Re: Similar Topics

Post by Stoker »

I found a tiny bug in the viewtopic_body.html part.
First post is updated.

For you who allready have installed this, find:

Code: Select all

<a href="{similar.U_FORUM}"><strong>{similar.FORUM}</strong>
Replace with:

Code: Select all

<a href="{similar.U_FORUM}"><strong>{similar.FORUM}</strong></a>
Board rules! No PM support
plasmino
BBCoder II
BBCoder II
Posts: 14
Joined: 27 Mar 2010, 10:36

Re: Similar Topics

Post by plasmino »

very nice thanks
User avatar
wagu
BBCoder II
BBCoder II
Posts: 10
Joined: 14 Mar 2010, 04:13
Location: Chile

Re: Similar Topics

Post by wagu »

Hello very nice Stoker. One question: I Need change in spanish some parts. Where Can I modify in this MOD? :D
In this part: Similar Topics, Replies, views, author:

Image
Mi foro
VISION
Locked