[DEV] Precise Similar Topics

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
Akbaio
Registered User
Posts: 49
Joined: Fri Dec 05, 2008 1:33 am

Re: [DEV] Precise Similar Topics

Post by Akbaio »

knmt wrote:I find the request for search ignore keywords a little old but here's what I have come up with:

Open Viewtopic.php
Find:

Code: Select all

$auth->acl($user->data);
Add After:

Code: Select all

$user->setup('search');
Find:

Code: Select all

// Begin Precise Similar Topics
Add Before:

Code: Select all

// Begin Filter Keywords for similar
	$num_keywords = sizeof(explode(' ', $topic_data['topic_title']));
	if ($num_keywords <= $config['max_num_search_keywords']) {

	$search_type = basename($config['search_type']);

	if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
	{
		trigger_error('NO_SUCH_SEARCH_MODULE');
	}

	require("{$phpbb_root_path}includes/search/$search_type.$phpEx");

	// We do some additional checks in the module to ensure it can actually be utilised
	$error = false;
	$search = new $search_type($error);

	if ($error)
	{
		trigger_error($error);
	}	
	$correct_query = $search->split_keywords($topic_data['topic_title'], 'any');	
	$similar_search_string = ($correct_query) ? str_replace(array("|","(",")"), " ", $search->search_query) : $topic_data['topic_title'];	
	$similar_search_keywords = explode(" ",trim($similar_search_string));
	foreach ($similar_search_keywords as &$value) {
		if (in_array($value,$search->common_words)) {
			$value = '';
		}
	}
	$similar_search_string = trim(implode(" ",$similar_search_keywords)); }
	
	else $similar_search_string = $topic_data['topic_title'];
// End of Filter Keywords for similar
Find: (2 times)

Code: Select all

$db->sql_escape($topic_data['topic_title'])
Replace with:

Code: Select all

$db->sql_escape($similar_search_string)
Please note that this will eliminate a lot of similar topics as you have requested but still no caching work is done here. This will also eliminate all search terms that are too common on the forum, so ahh...enjoy :lol:. Btw, this is just a basic way to do this, any other ideas are appreciated.

Sorry Knmt, but this won't work. I checked and ignore words listed in search_ignore_words.php are matched again in the similar topics list. :(
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

Well it works but not for topic titles that are longer than your maximum keywords defined in your ACP. Anyway, I've found a function that works well (I was too lazy to create one hehe).

Here, copy and save this as "functions_related_topics.php" in your includes folder:

Code: Select all

<?php
   	/* borrowed from phpbb-seo related topics
	* prepare_match : Prepares the word list to search for
	* @param	string	$text		the string of all words to search for, eg topic_title
	* @param	int	$min_lenght	word with less than $min_lenght letters will be dropped
	* @param	int	$max_lenght	word with more than $max_lenght letters will be dropped
	*/
	function prepare_match($text, $min_lenght = 3, $max_lenght = 14) {
		$word_list = array();
		$text = trim(preg_replace('`[\s]+`', ' ', $text));
		if (!empty($text)) {
			$word_list = array_unique(explode(' ', utf8_strtolower($text)));
			foreach ($word_list as $k => $word) {
				$len = utf8_strlen(trim($word));
				if ( ($len < $min_lenght) || ($len > $max_lenght) ) {
					unset($word_list[$k]);
				}
			}
		}
		if (!empty($word_list)) {
			global $phpbb_root_path, $user, $phpEx;
			// add stop words to $user to allow reuse
			if (empty($user->stop_words)) {
				$words = array();
				if (file_exists("{$user->lang_path}{$user->lang_name}/search_ignore_words.$phpEx")){
					// include the file containing ignore words
					include("{$user->lang_path}{$user->lang_name}/search_ignore_words.$phpEx");
				}
				$user->stop_words = & $words;
			}
			$word_list = array_diff($word_list, $user->stop_words);
		}
		return !empty($word_list) ? implode(' ', $word_list) : '';
	}
?>
Then, open viewtopic.php
Find the block from:

Code: Select all

// Begin Filter Keywords for similar
to

Code: Select all

// End of Filter Keywords for similar
Replace with:

Code: Select all

include($phpbb_root_path . 'includes/functions_related_topics.' . $phpEx);
$similar_search_string = prepare_match($topic_data['topic_title']);
There you go ;).
Akbaio
Registered User
Posts: 49
Joined: Fri Dec 05, 2008 1:33 am

Re: [DEV] Precise Similar Topics

Post by Akbaio »

No, it won't works, words listed in search_ignore_words.php are matched in similar topics list again. :cry:
Maybe I have to recreate search index because search_ignore_words.php won't works also in regular search: when I search a term included in the list I find it.

I tried locally: I deleted old index and recreated search index but search_ignore_words.php list won't works! (I use Fulltext native) I think this list is completely useless, anyone knows why search_ignore_words doesn't work in phpbb3? :shock:

Knmt can we create an independent list of stop words and call it from the similar function?
Last edited by stickerboy on Mon Feb 08, 2010 10:56 am, edited 2 times in total.
Reason: Posts merged - please use the edit button in future to add more information - http://www.phpbb.com/rules/#rule4g
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

Are you sure? It's working right now on my forum. And in the function I copied from phpbb-seo, they actually included the search_gnore_words.php file and did some replacement with words in there, so it must work. Maybe it's some problem with your language file and code. May I see your viewtopic.php and what language are you using?
newn
Registered User
Posts: 98
Joined: Fri Apr 25, 2008 6:06 pm

Re: [DEV] Precise Similar Topics

Post by newn »

How can i make this work with subsilver2 template? It doesn't not show anything after i add this code after that line like in prosilver(yes, i'v cleaned my cache).
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

The instruction you used is for prosilver so it may have some problem. May I see your viewtopic_body.html? It will be an easy fix I suppose ;)
newn
Registered User
Posts: 98
Joined: Fri Apr 25, 2008 6:06 pm

Re: [DEV] Precise Similar Topics

Post by newn »

Here it is:

Code: Select all

<!-- INCLUDE overall_header.html -->

<!-- IF S_FORUM_RULES -->
	<div class="forumrules">
		<!-- IF U_FORUM_RULES -->
			<h3>{L_FORUM_RULES}</h3><br />
			<a href="{U_FORUM_RULES}"><b>{L_FORUM_RULES_LINK}</b></a>
		<!-- ELSE -->
			<h3>{L_FORUM_RULES}</h3><br />
			{FORUM_RULES}
		<!-- ENDIF -->
	</div>

	<br clear="all" />
<!-- ENDIF -->

<!-- IF S_DISPLAY_ACTIVE -->
	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="cat" colspan="<!-- IF S_TOPIC_ICONS -->7<!-- ELSE -->6<!-- ENDIF -->"><span class="nav">{L_ACTIVE_TOPICS}</span></td>
	</tr>

	<tr>
		<!-- IF S_TOPIC_ICONS -->
			<th colspan="3">&nbsp;{L_TOPICS}&nbsp;</th>
		<!-- ELSE -->
			<th colspan="2">&nbsp;{L_TOPICS}&nbsp;</th>
		<!-- ENDIF -->
		<th>&nbsp;{L_AUTHOR}&nbsp;</th>
		<th>&nbsp;{L_REPLIES}&nbsp;</th>
		<th>&nbsp;{L_VIEWS}&nbsp;</th>
		<th>&nbsp;{L_LAST_POST}&nbsp;</th>
	</tr>

	<!-- BEGIN topicrow -->

		<tr>
			<td class="row1" width="25" align="center">{topicrow.TOPIC_FOLDER_IMG}</td>
			<!-- IF S_TOPIC_ICONS -->
				<td class="row1" width="25" align="center"><!-- IF topicrow.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}" width="{topicrow.TOPIC_ICON_IMG_WIDTH}" height="{topicrow.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td>
			<!-- ENDIF -->
			<td class="row1">
				<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a><!-- ENDIF -->
				{topicrow.ATTACH_ICON_IMG} <!-- IF topicrow.S_HAS_POLL or topicrow.S_TOPIC_MOVED --><b>{topicrow.TOPIC_TYPE}</b> <!-- ENDIF --><a title="{L_POSTED}: {topicrow.FIRST_POST_TIME}" href="{topicrow.U_VIEW_TOPIC}"class="topictitle">{topicrow.TOPIC_TITLE}</a>
				<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED -->
					<a href="{topicrow.U_MCP_QUEUE}">{UNAPPROVED_IMG}</a>&nbsp;
				<!-- ENDIF -->
				<!-- IF topicrow.S_TOPIC_REPORTED -->
					<a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
				<!-- ENDIF -->
				<!-- IF topicrow.PAGINATION -->
					<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
				<!-- ENDIF -->
			</td>
			<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
			<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>
			<td class="row2" width="50" align="center"><p class="topicdetails">{topicrow.VIEWS}</p></td>
			<td class="row1" width="140" align="center">
				<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
				<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
					<!-- IF not S_IS_BOT --><a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a><!-- ENDIF -->
				</p>
			</td>
		</tr>

	<!-- BEGINELSE -->

		<tr>
			<!-- IF S_TOPIC_ICONS -->
				<td class="row1" colspan="7" height="30" align="center" valign="middle"><span class="gen"><!-- IF not S_SORT_DAYS -->{L_NO_TOPICS}<!-- ELSE -->{L_NO_TOPICS_TIME_FRAME}<!-- ENDIF --></span></td>
			<!-- ELSE -->
				<td class="row1" colspan="6" height="30" align="center" valign="middle"><span class="gen"><!-- IF not S_SORT_DAYS -->{L_NO_TOPICS}<!-- ELSE -->{L_NO_TOPICS_TIME_FRAME}<!-- ENDIF --></span></td>
			<!-- ENDIF -->
		</tr>
	<!-- END topicrow -->

	<tr align="center">
		<td class="cat" colspan="<!-- IF S_TOPIC_ICONS -->7<!-- ELSE -->6<!-- ENDIF -->">&nbsp;</td>
	</tr>
	</table>

	<br clear="all" />
<!-- ENDIF -->

<!-- IF S_HAS_SUBFORUM -->
	<!-- INCLUDE forumlist_body.html -->
	<br clear="all" />
<!-- ENDIF -->

<!-- IF S_IS_POSTABLE or S_NO_READ_ACCESS -->
	<div id="pageheader">
		<h2><a class="titles" href="{U_VIEW_FORUM}">{FORUM_NAME}</a></h2>

		<!-- IF MODERATORS -->
			<p class="moderators"><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE -->{L_MODERATORS}<!-- ENDIF -->: {MODERATORS}</p>
		<!-- ENDIF -->
		<!-- IF U_MCP -->
			<p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
		<!-- ENDIF -->
	</div>

	<br clear="all" /><br />
<!-- ENDIF -->

<div id="pagecontent">

<!-- IF S_NO_READ_ACCESS -->
	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="row1" height="30" align="center" valign="middle"><span class="gen">{L_NO_READ_ACCESS}</span></td>
	</tr>
	</table>

	<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->

		<br /><br />

		<form method="post" action="{S_LOGIN_ACTION}">

		<table class="tablebg" width="100%" cellspacing="1">
		<tr>
			<td class="cat"><h4><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a></h4></td>
		</tr>
		<tr>
			<td class="row1" align="center"><span class="genmed">{L_USERNAME}:</span> <input class="post" type="text" name="username" size="10" />&nbsp; <span class="genmed">{L_PASSWORD}:</span> <input class="post" type="password" name="password" size="10" /><!-- IF S_AUTOLOGIN_ENABLED -->&nbsp; <span class="gensmall">{L_LOG_ME_IN}</span> <input type="checkbox" class="radio" name="autologin" /><!-- ENDIF -->&nbsp; <input type="submit" class="btnmain" name="login" value="{L_LOGIN}" /></td>
		</tr>
		</table>

		</form>

	<!-- ENDIF -->

	<br clear="all" />
<!-- ENDIF -->

	<!-- IF S_DISPLAY_POST_INFO or TOTAL_TOPICS -->
		<table width="100%" cellspacing="1">
		<tr>
			<!-- IF S_DISPLAY_POST_INFO and not S_IS_BOT -->
				<td align="{S_CONTENT_FLOW_BEGIN}" valign="middle"><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a></td>
			<!-- ENDIF -->
			<!-- IF TOTAL_TOPICS -->
				<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
				<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_TOPICS} ]&nbsp;</td>
				<td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
			<!-- ENDIF -->
		</tr>
		</table>
	<!-- ENDIF -->

	<!-- IF not S_DISPLAY_ACTIVE and (S_IS_POSTABLE or .topicrow) -->
		<table class="tablebg" width="100%" cellspacing="1">
		<tr>
			<td class="cat" colspan="<!-- IF S_TOPIC_ICONS -->7<!-- ELSE -->6<!-- ENDIF -->">
				<table width="100%" cellspacing="0">
				<tr class="nav">
					<td valign="middle">&nbsp;<!-- IF S_WATCH_FORUM_LINK and not S_IS_BOT --><a href="{S_WATCH_FORUM_LINK}">{S_WATCH_FORUM_TITLE}</a><!-- ENDIF --></td>
					<td align="{S_CONTENT_FLOW_END}" valign="middle"><!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- ENDIF -->&nbsp;</td>
				</tr>
				</table>
			</td>
		</tr>

		<tr>
			<!-- IF S_TOPIC_ICONS -->
				<th colspan="3">&nbsp;{L_TOPICS}&nbsp;</th>
			<!-- ELSE -->
				<th colspan="2">&nbsp;{L_TOPICS}&nbsp;</th>
			<!-- ENDIF -->
			<th>&nbsp;{L_AUTHOR}&nbsp;</th>
			<th>&nbsp;{L_REPLIES}&nbsp;</th>
			<th>&nbsp;{L_VIEWS}&nbsp;</th>
			<th>&nbsp;{L_LAST_POST}&nbsp;</th>
		</tr>

		<!-- BEGIN topicrow -->

			<!-- IF topicrow.S_TOPIC_TYPE_SWITCH eq 1 -->
				<tr>
					<td class="row3" colspan="<!-- IF S_TOPIC_ICONS -->7<!-- ELSE -->6<!-- ENDIF -->"><b class="gensmall">{L_ANNOUNCEMENTS}</b></td>
				</tr>
			<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH eq 0 -->
				<tr>
					<td class="row3" colspan="<!-- IF S_TOPIC_ICONS -->7<!-- ELSE -->6<!-- ENDIF -->"><b class="gensmall">{L_TOPICS}</b></td>
				</tr>
			<!-- ENDIF -->

			<tr>
				<td class="row1" width="25" align="center">{topicrow.TOPIC_FOLDER_IMG}</td>
				<!-- IF S_TOPIC_ICONS -->
					<td class="row1" width="25" align="center"><!-- IF topicrow.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}" width="{topicrow.TOPIC_ICON_IMG_WIDTH}" height="{topicrow.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td>
				<!-- ENDIF -->
				<td class="row1">
					<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a><!-- ENDIF -->
					{topicrow.ATTACH_ICON_IMG} <!-- IF topicrow.S_HAS_POLL or topicrow.S_TOPIC_MOVED --><b>{topicrow.TOPIC_TYPE}</b> <!-- ENDIF --><a title="{L_POSTED}: {topicrow.FIRST_POST_TIME}" href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
					<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED -->
						<a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a>&nbsp;
					<!-- ENDIF -->
					<!-- IF topicrow.S_TOPIC_REPORTED -->
						<a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
					<!-- ENDIF -->
					<!-- IF topicrow.PAGINATION -->
						<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
					<!-- ENDIF -->
				</td>
				<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
				<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>
				<td class="row2" width="50" align="center"><p class="topicdetails">{topicrow.VIEWS}</p></td>
				<td class="row1" width="140" align="center">
					<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
					<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
						<!-- IF not S_IS_BOT --><a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a><!-- ENDIF -->
					</p>
				</td>
			</tr>

		<!-- BEGINELSE -->
			<!-- IF S_IS_POSTABLE -->
			<tr>
				<!-- IF S_TOPIC_ICONS -->
					<td class="row1" colspan="7" height="30" align="center" valign="middle"><span class="gen"><!-- IF not S_SORT_DAYS -->{L_NO_TOPICS}<!-- ELSE -->{L_NO_TOPICS_TIME_FRAME}<!-- ENDIF --></span></td>
				<!-- ELSE -->
					<td class="row1" colspan="6" height="30" align="center" valign="middle"><span class="gen"><!-- IF not S_SORT_DAYS -->{L_NO_TOPICS}<!-- ELSE -->{L_NO_TOPICS_TIME_FRAME}<!-- ENDIF --></span></td>
				<!-- ENDIF -->
			</tr>
			<!-- ENDIF -->
		<!-- END topicrow -->

		<!-- IF not S_IS_BOT -->
		<tr align="center">
			<!-- IF S_TOPIC_ICONS -->
				<td class="cat" colspan="7">
			<!-- ELSE -->
				<td class="cat" colspan="6">
			<!-- ENDIF -->
					<form method="post" action="{S_FORUM_ACTION}"><span class="gensmall">{L_DISPLAY_TOPICS}:</span>&nbsp;{S_SELECT_SORT_DAYS}&nbsp;<span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR}&nbsp;<input class="btnlite" type="submit" name="sort" value="{L_GO}" /></form>
				</td>
		</tr>
		<!-- ENDIF -->
		</table>
	<!-- ENDIF -->

	<!-- IF S_DISPLAY_POST_INFO or TOTAL_TOPICS -->
		<table width="100%" cellspacing="1">
		<tr>
			<!-- IF S_DISPLAY_POST_INFO and not S_IS_BOT -->
				<td align="{S_CONTENT_FLOW_BEGIN}" valign="middle"><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a></td>
			<!-- ENDIF -->
			<!-- IF TOTAL_TOPICS -->
				<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
				<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_TOPICS} ]&nbsp;</td>
				<td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
			<!-- ENDIF -->
		</tr>
		</table>
	<!-- ENDIF -->

		<br clear="all" />
</div>

<!-- INCLUDE breadcrumbs.html -->

<!-- IF S_DISPLAY_ONLINE_LIST -->
	<br clear="all" />

	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="cat"><h4>{L_WHO_IS_ONLINE}</h4></td>
	</tr>
	<tr>
		<td class="row1"><p class="gensmall">{LOGGED_IN_USER_LIST}</p></td>
	</tr>
	</table>
<!-- ENDIF -->

<!-- IF S_DISPLAY_POST_INFO -->
	<br clear="all" />

	<table width="100%" cellspacing="0">
	<tr>
		<td align="{S_CONTENT_FLOW_BEGIN}" valign="top">
			<table cellspacing="3" cellpadding="0" border="0">
			<tr>
				<td width="20" style="text-align: center;">{FOLDER_NEW_IMG}</td>
				<td class="gensmall">{L_NEW_POSTS}</td>
				<td>&nbsp;&nbsp;</td>
				<td width="20" style="text-align: center;">{FOLDER_IMG}</td>
				<td class="gensmall">{L_NO_NEW_POSTS}</td>
				<td>&nbsp;&nbsp;</td>
				<td width="20" style="text-align: center;">{FOLDER_ANNOUNCE_IMG}</td>
				<td class="gensmall">{L_ICON_ANNOUNCEMENT}</td>
			</tr>
			<tr>
				<td style="text-align: center;">{FOLDER_HOT_NEW_IMG}</td>
				<td class="gensmall">{L_NEW_POSTS_HOT}</td>
				<td>&nbsp;&nbsp;</td>
				<td style="text-align: center;">{FOLDER_HOT_IMG}</td>
				<td class="gensmall">{L_NO_NEW_POSTS_HOT}</td>
				<td>&nbsp;&nbsp;</td>
				<td style="text-align: center;">{FOLDER_STICKY_IMG}</td>
				<td class="gensmall">{L_ICON_STICKY}</td>
			</tr>
			<tr>
				<td style="text-align: center;">{FOLDER_LOCKED_NEW_IMG}</td>
				<td class="gensmall">{L_NEW_POSTS_LOCKED}</td>
				<td>&nbsp;&nbsp;</td>
				<td style="text-align: center;">{FOLDER_LOCKED_IMG}</td>
				<td class="gensmall">{L_NO_NEW_POSTS_LOCKED}</td>
				<td>&nbsp;&nbsp;</td>
				<td style="text-align: center;">{FOLDER_MOVED_IMG}</td>
				<td class="gensmall">{L_TOPIC_MOVED}</td>
			</tr>
			</table>
		</td>
		<td align="{S_CONTENT_FLOW_END}"><span class="gensmall"><!-- BEGIN rules -->{rules.RULE}<br /><!-- END rules --></span></td>
	</tr>
	</table>
<!-- ENDIF -->

<br clear="all" />

<table width="100%" cellspacing="0">
<tr>
	<td><!-- IF S_DISPLAY_SEARCHBOX --><!-- INCLUDE searchbox.html --><!-- ENDIF --></td>
	<td align="{S_CONTENT_FLOW_END}"><!-- INCLUDE jumpbox.html --></td>
</tr>
</table>

<!-- INCLUDE overall_footer.html -->
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

O.o you copied the viewforum_body.html not the viewtopic_body.html :lol:
newn
Registered User
Posts: 98
Joined: Fri Apr 25, 2008 6:06 pm

Re: [DEV] Precise Similar Topics

Post by newn »

Here you go.

Code: Select all

<!-- INCLUDE overall_header.html -->

<!-- IF S_FORUM_RULES -->
	<div class="forumrules">
		<!-- IF U_FORUM_RULES -->
			<h3>{L_FORUM_RULES}</h3><br />
			<a href="{U_FORUM_RULES}"><b>{L_FORUM_RULES_LINK}</b></a>
		<!-- ELSE -->
			<h3>{L_FORUM_RULES}</h3><br />
			{FORUM_RULES}
		<!-- ENDIF -->
	</div>

	<br clear="all" />
<!-- ENDIF -->

<div id="pageheader">
	<h2><a class="titles" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a></h2>

<!-- IF MODERATORS -->
	<p class="moderators"><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE -->{L_MODERATORS}<!-- ENDIF -->: {MODERATORS}</p>
<!-- ENDIF -->
<!-- IF U_MCP -->
	<p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
<!-- ENDIF -->
</div>

<br clear="all" /><br />

<div id="pagecontent">

	<table width="100%" cellspacing="1">
	<tr>
		<td align="{S_CONTENT_FLOW_BEGIN}" valign="middle" nowrap="nowrap">
		<!-- IF not S_IS_BOT -->
			<!-- IF S_DISPLAY_POST_INFO --><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a>&nbsp;<!-- ENDIF -->
			<!-- IF S_DISPLAY_REPLY_INFO --><a href="{U_POST_REPLY_TOPIC}">{REPLY_IMG}</a><!-- ENDIF -->
		<!-- ENDIF -->
		</td>
		<!-- IF TOTAL_POSTS -->
			<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
			<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_POSTS} ]&nbsp;</td>
			<td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
		<!-- ENDIF -->
	</tr>
	</table>

	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="cat">
			<table width="100%" cellspacing="0">
			<tr>
				<td class="nav" nowrap="nowrap">&nbsp;
				<!-- IF not S_IS_BOT -->
					<!-- IF U_WATCH_TOPIC --><a href="{U_WATCH_TOPIC}" title="{L_WATCH_TOPIC}">{L_WATCH_TOPIC}</a><!-- IF U_PRINT_TOPIC or U_EMAIL_TOPIC or U_BUMP_TOPIC or U_BOOKMARK_TOPIC --> | <!-- ENDIF --><!-- ENDIF -->
					<!-- IF U_BOOKMARK_TOPIC --><a href="{U_BOOKMARK_TOPIC}" title="{L_BOOKMARK_TOPIC}">{L_BOOKMARK_TOPIC}</a><!-- IF U_PRINT_TOPIC or U_EMAIL_TOPIC or U_BUMP_TOPIC --> | <!-- ENDIF --><!-- ENDIF -->
					<!-- IF U_PRINT_TOPIC --><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}">{L_PRINT_TOPIC}</a><!-- IF U_EMAIL_TOPIC or U_BUMP_TOPIC --> | <!-- ENDIF --><!-- ENDIF -->
					<!-- IF U_EMAIL_TOPIC --><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}">{L_EMAIL_TOPIC}</a><!-- IF U_BUMP_TOPIC --> | <!-- ENDIF --><!-- ENDIF -->
					<!-- IF U_BUMP_TOPIC --><a href="{U_BUMP_TOPIC}" title="{L_BUMP_TOPIC}">{L_BUMP_TOPIC}</a><!-- ENDIF -->
				<!-- ENDIF -->
				</td>
				<td class="nav" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><a href="{U_VIEW_OLDER_TOPIC}">{L_VIEW_PREVIOUS_TOPIC}</a><!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --> | <a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a><!-- ENDIF --> | <a href="{U_VIEW_NEWER_TOPIC}">{L_VIEW_NEXT_TOPIC}</a>&nbsp;</td>
			</tr>
			</table>
		</td>
	</tr>
<!-- IF S_HAS_POLL -->
	<tr>
		<td class="row2" colspan="2" align="center"><br clear="all" />

			<form method="post" action="{S_POLL_ACTION}">

			<table cellspacing="0" cellpadding="4" border="0" align="center">
			<tr>
				<td align="center"><span class="gen"><b>{POLL_QUESTION}</b></span><br /><span class="gensmall">{L_POLL_LENGTH}</span></td>
			</tr>
			<tr>
				<td align="{S_CONTENT_FLOW_BEGIN}">
					<table cellspacing="0" cellpadding="2" border="0">
				<!-- BEGIN poll_option -->
					<tr>
					<!-- IF S_CAN_VOTE -->
						<td>
							<!-- IF S_IS_MULTI_CHOICE -->
								<input type="checkbox" class="radio" name="vote_id[]" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> />
							<!-- ELSE -->
								<input type="radio" class="radio" name="vote_id[]" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> />
							<!-- ENDIF -->
						</td>
					<!-- ENDIF -->
						<td><span class="gen">{poll_option.POLL_OPTION_CAPTION}</span></td>
						<!-- IF S_DISPLAY_RESULTS -->
							<td dir="ltr">{POLL_LEFT_CAP_IMG}{poll_option.POLL_OPTION_IMG}{POLL_RIGHT_CAP_IMG}</td>
							<td class="gen" align="{S_CONTENT_FLOW_END}"><b>&nbsp;{poll_option.POLL_OPTION_PERCENT}&nbsp;</b></td>
							<td class="gen" align="center">[ {poll_option.POLL_OPTION_RESULT} ]</td>
							<!-- IF poll_option.POLL_OPTION_VOTED -->
								<td class="gensmall" valign="top"><b title="{L_POLL_VOTED_OPTION}">x</b></td>
							<!-- ENDIF -->
						<!-- ENDIF -->
					</tr>
				<!-- END poll_option -->
					</table>
				</td>
			</tr>
		<!-- IF S_CAN_VOTE -->
			<tr>
				<td align="center"><span class="gensmall">{L_MAX_VOTES}</span><br /><br /><input type="submit" name="update" value="{L_SUBMIT_VOTE}" class="btnlite" /></td>
			</tr>
		<!-- ENDIF -->
		<!-- IF S_DISPLAY_RESULTS -->
			<tr>
				<td class="gensmall" colspan="4" align="center"><b>{L_TOTAL_VOTES} : {TOTAL_VOTES}</b></td>
			</tr>
		<!-- ELSE -->
			<tr>
				<td align="center"><span class="gensmall"><b><a href="{U_VIEW_RESULTS}">{L_VIEW_RESULTS}</a></b></span></td>
			</tr>
		<!-- ENDIF -->
			</table>
			{S_HIDDEN_FIELDS}
			{S_FORM_TOKEN}
			</form>

		</td>
	</tr>
<!-- ENDIF -->
	</table>

<!-- BEGIN postrow -->
	<table class="tablebg" width="100%" cellspacing="1">
	<!-- IF postrow.S_FIRST_ROW -->
		<tr>
			<th>{L_AUTHOR}</th>
			<th>{L_MESSAGE}</th>
		</tr>
	<!-- ENDIF -->
	<!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->

	<!-- IF postrow.S_IGNORE_POST -->
			<td class="gensmall" colspan="2" height="25" align="center"><!-- IF postrow.S_FIRST_UNREAD --><a name="unread"></a><!-- ENDIF --><a name="p{postrow.POST_ID}"></a>{postrow.L_IGNORE_POST}</td>
	<!-- ELSE -->

			<td align="center" valign="middle">
				<!-- IF postrow.S_FIRST_UNREAD --><a name="unread"></a><!-- ENDIF --><a name="p{postrow.POST_ID}"></a>
				<b class="postauthor"<!-- IF postrow.POST_AUTHOR_COLOUR --> style="color: {postrow.POST_AUTHOR_COLOUR}"<!-- ENDIF -->>{postrow.POST_AUTHOR}</b>
			</td>
			<td width="100%" height="25">
				<table width="100%" cellspacing="0">
				<tr>
				<!-- IF postrow.POST_ICON_IMG -->
					<td><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" title="" /></td>
				<!-- ENDIF -->
					<td class="gensmall" width="100%"><div style="float: {S_CONTENT_FLOW_BEGIN};">&nbsp;<b>{L_POST_SUBJECT}:</b> {postrow.POST_SUBJECT}</div><div style="float: {S_CONTENT_FLOW_END};"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF --><b>{L_POSTED}:</b> {postrow.POST_DATE}&nbsp;</div></td>
				</tr>
				</table>
			</td>
		</tr>

		<!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->

			<td valign="top" class="profile">
				<table cellspacing="4" align="center" width="150">
			<!-- IF postrow.ONLINE_IMG -->
				<tr>
					<td>{postrow.ONLINE_IMG}</td>
				</tr>
			<!-- ENDIF -->
			<!-- IF postrow.RANK_TITLE -->
				<tr>
					<td class="postdetails">{postrow.RANK_TITLE}</td>
				</tr>
			<!-- ENDIF -->
			<!-- IF postrow.RANK_IMG -->
				<tr>
					<td>{postrow.RANK_IMG}</td>
				</tr>
			<!-- ENDIF -->
			<!-- IF postrow.POSTER_AVATAR -->
				<tr>
					<td>{postrow.POSTER_AVATAR}</td>
				</tr>
			<!-- ENDIF -->
			<!-- IF not (postrow.ONLINE_IMG or postrow.RANK_TITLE or postrow.RANK_IMG or postrow.POSTER_AVATAR) -->
				<tr>
					<td></td>
				</tr>
			<!-- ENDIF -->
				</table>

				<span class="postdetails">
					<!-- IF postrow.POSTER_JOINED --><br /><b>{L_JOINED}:</b> {postrow.POSTER_JOINED}<!-- ENDIF -->
					<!-- IF postrow.POSTER_POSTS != '' --><br /><b>{L_POSTS}:</b> {postrow.POSTER_POSTS}<!-- ENDIF -->
					<!-- IF postrow.POSTER_FROM --><br /><b>{L_LOCATION}:</b> {postrow.POSTER_FROM}<!-- ENDIF -->

					<!-- IF postrow.S_PROFILE_FIELD1 -->
						<!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
						<br /><b>{postrow.PROFILE_FIELD1_NAME}:</b> {postrow.PROFILE_FIELD1_VALUE}
					<!-- ENDIF -->

					<!-- BEGIN custom_fields -->
						<br /><b>{postrow.custom_fields.PROFILE_FIELD_NAME}:</b> {postrow.custom_fields.PROFILE_FIELD_VALUE}
					<!-- END custom_fields -->
				</span>

			</td>
			<td valign="top">
				<table width="100%" cellspacing="5">
				<tr>
					<td>
					<!-- IF postrow.S_POST_UNAPPROVED or postrow.S_POST_REPORTED -->
						<table width="100%" cellspacing="0">
						<tr>
							<td class="gensmall"><!-- IF postrow.S_POST_UNAPPROVED --><span class="postapprove">{UNAPPROVED_IMG} <a href="{postrow.U_MCP_APPROVE}">{L_POST_UNAPPROVED}</a></span><br /> <!-- ENDIF --> <!-- IF postrow.S_POST_REPORTED --><span class="postreported">{REPORTED_IMG} <a href="{postrow.U_MCP_REPORT}">{L_POST_REPORTED}</a></span><!-- ENDIF --></td>
						</tr>
						</table>

						<br clear="all" />
					<!-- ENDIF -->

						<div class="postbody">{postrow.MESSAGE}</div>

					<!-- IF postrow.S_HAS_ATTACHMENTS -->
						<br clear="all" /><br />

						<table class="tablebg" width="100%" cellspacing="1">
						<tr>
							<td class="row3"><b class="genmed">{L_ATTACHMENTS}: </b></td>
						</tr>
						<!-- BEGIN attachment -->
							<tr>
								<!-- IF postrow.attachment.S_ROW_COUNT is even --><td class="row2"><!-- ELSE --><td class="row1"><!-- ENDIF -->{postrow.attachment.DISPLAY_ATTACHMENT}</td>
							</tr>
						<!-- END attachment -->
						</table>
					<!-- ENDIF -->

					<!-- IF postrow.S_DISPLAY_NOTICE -->
						<span class="gensmall error"><br /><br />{L_DOWNLOAD_NOTICE}</span>
					<!-- ENDIF -->
					<!-- IF postrow.SIGNATURE -->
						<span class="postbody"><br />_________________<br />{postrow.SIGNATURE}</span>
					<!-- ENDIF -->

					<!-- IF postrow.EDITED_MESSAGE or postrow.EDIT_REASON -->
						<!-- IF postrow.EDIT_REASON -->
							<br /><br />
							<table class="tablebg" width="100%" cellspacing="1">
							<tr>
								<td class="row3"><span class="gensmall">{postrow.EDITED_MESSAGE}</span></td>
							</tr>
							<tr>
								<td class="row2"><span class="genmed">{postrow.EDIT_REASON}</span></td>
							</tr>
							</table>
						<!-- ELSE -->
							<br /><br />
							<span class="gensmall">{postrow.EDITED_MESSAGE}</span>
						<!-- ENDIF -->
					<!-- ENDIF -->

					<!-- IF postrow.BUMPED_MESSAGE -->
						<span class="gensmall"><br /><br />{postrow.BUMPED_MESSAGE}</span>
					<!-- ENDIF -->

					<!-- IF not postrow.S_HAS_ATTACHMENTS --><br clear="all" /><br /><!-- ENDIF -->

						<table width="100%" cellspacing="0">
						<tr valign="middle">
							<td class="gensmall" align="{S_CONTENT_FLOW_END}">
							<!-- IF not S_IS_BOT -->
								<!-- IF postrow.U_REPORT --><a href="{postrow.U_REPORT}">{REPORT_IMG}</a> <!-- ENDIF --> 
								<!-- IF postrow.U_INFO --><a href="{postrow.U_INFO}">{INFO_IMG}</a> <!-- ENDIF --> 
								<!-- IF postrow.U_WARN --><a href="{postrow.U_WARN}">{WARN_IMG}</a> <!-- ENDIF --> 
								<!-- IF postrow.U_DELETE --><a href="{postrow.U_DELETE}">{DELETE_IMG}</a> <!-- ENDIF -->
							<!-- ENDIF -->
							</td>
						</tr>
						</table>
					</td>
				</tr>
				</table>
			</td>
		</tr>

		<!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->

			<td class="profile"><strong><a href="#wrapheader">{L_BACK_TO_TOP}</a></strong></td>
			<td><div class="gensmall" style="float: {S_CONTENT_FLOW_BEGIN};">&nbsp;<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{PROFILE_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_PM --><a href="{postrow.U_PM}">{PM_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_EMAIL --><a href="{postrow.U_EMAIL}">{EMAIL_IMG}</a> <!-- ENDIF -->&nbsp;</div> <div class="gensmall" style="float: {S_CONTENT_FLOW_END};"><!-- IF not S_IS_BOT --><!-- IF postrow.U_EDIT --><a href="{postrow.U_EDIT}">{EDIT_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_QUOTE --><a href="{postrow.U_QUOTE}">{QUOTE_IMG}</a> <!-- ENDIF --> <!-- ENDIF -->&nbsp;</div></td>
	<!-- ENDIF -->
		</tr>

	<tr>
		<td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
	</tr>
	</table>
<!-- END postrow -->

	<!-- IF not S_IS_BOT -->
	<table width="100%" cellspacing="1" class="tablebg">
	<tr align="center">
		<td class="cat"><form name="viewtopic" method="post" action="{S_TOPIC_ACTION}"><span class="gensmall">{L_DISPLAY_POSTS}:</span> {S_SELECT_SORT_DAYS}&nbsp;<span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR}&nbsp;<input class="btnlite" type="submit" value="{L_GO}" name="sort" /></form></td>
	</tr>
	</table>
	<!-- ENDIF -->

	<table width="100%" cellspacing="1">
	<tr>
		<td align="{S_CONTENT_FLOW_BEGIN}" valign="middle" nowrap="nowrap">
		<!-- IF not S_IS_BOT -->
			<!-- IF S_DISPLAY_POST_INFO --><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a>&nbsp;<!-- ENDIF -->
			<!-- IF S_DISPLAY_REPLY_INFO --><a href="{U_POST_REPLY_TOPIC}">{REPLY_IMG}</a><!-- ENDIF -->
		<!-- ENDIF -->
		</td>
		<!-- IF TOTAL_POSTS -->
			<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
			<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_POSTS} ]&nbsp;</td>
			<td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
		<!-- ENDIF -->
	</tr>
	</table>

</div>

<div id="pagefooter"></div>

<br clear="all" />
<!-- IF S_QUICK_REPLY -->
<!-- INCLUDE quickreply_editor.html -->
<!-- ENDIF -->

<!-- INCLUDE breadcrumbs.html -->

<!-- IF S_DISPLAY_ONLINE_LIST -->
	<br clear="all" />

	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="cat"><h4>{L_WHO_IS_ONLINE}</h4></td>
	</tr>
	<tr>
		<td class="row1"><p class="gensmall">{LOGGED_IN_USER_LIST}</p></td>
	</tr>
	</table>
<!-- ENDIF -->

<br clear="all" />

<table width="100%" cellspacing="1">
<tr>
	<td width="40%" valign="top" nowrap="nowrap" align="{S_CONTENT_FLOW_BEGIN}"><!-- IF S_TOPIC_MOD --><form method="post" action="{S_MOD_ACTION}"><span class="gensmall">{L_QUICK_MOD}:</span> {S_TOPIC_MOD} <input class="btnlite" type="submit" value="{L_GO}" /></form><!-- ENDIF --></td>
	<td align="{S_CONTENT_FLOW_END}" valign="top" nowrap="nowrap"><span class="gensmall"><!-- BEGIN rules -->{rules.RULE}<br /><!-- END rules --></span></td>
</tr>
</table>

<br clear="all" />

<table width="100%" cellspacing="0">
<tr>
	<td><!-- IF S_DISPLAY_SEARCHBOX --><!-- INCLUDE searchbox.html --><!-- ENDIF --></td>
	<td align="{S_CONTENT_FLOW_END}"><!-- INCLUDE jumpbox.html --></td>
</tr>
</table>

<!-- INCLUDE overall_footer.html -->
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

And here you go :lol:
Find:

Code: Select all

<!-- INCLUDE breadcrumbs.html --> 
Add After:

Code: Select all

<!-- IF .similar -->
    <br />
    <table class="tablebg" width="100%" cellspacing="1">
        <tr>
             <th style="text-align: left;">Similar Topics</th>
        </tr>
        <tr><td class="row1">
             <table width="100%">
             <tr>
                <!-- BEGIN similar -->
                <td width="20%" valign="top"><div style="margin: 5px;"><a href="{similar.U_TOPIC}" class="topictitle">{similar.TOPIC_TITLE}</a><br />
                   {L_FORUM}: <a href="{similar.U_FORUM}">{similar.FORUM}</a></div>
                </td>
                <!-- END similar -->
             </tr>
             </table>
        </td></tr>
    </table>
    <!-- ENDIF -->
 
newn
Registered User
Posts: 98
Joined: Fri Apr 25, 2008 6:06 pm

Re: [DEV] Precise Similar Topics

Post by newn »

Thanks! It's working!
Few more questions answered and my board's good to go online.
newn
Registered User
Posts: 98
Joined: Fri Apr 25, 2008 6:06 pm

Re: [DEV] Precise Similar Topics

Post by newn »

I upgraded it a little... Anyways, is there any way to make it write the poster and last post date (maybe even first post date too)?
User avatar
knmt
Registered User
Posts: 110
Joined: Fri Aug 29, 2008 10:13 am
Contact:

Re: [DEV] Precise Similar Topics

Post by knmt »

Since this mod doesn't have any kind of caching work, I would not recommend fetching too much data, but well, here you go: (assuming that the poster you mentioned is the last poster in that topic and you need his/her profile link with colour)

Find this Block:

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, 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'],
                'U_TOPIC'            => $similar_topic_url,
                'U_FORUM'            => $similar_forum_url,
                'FORUM'               => $similar['forum_name'])
             );
          }
       }
    }
    // End Precise Similar Topics
 
Replace With:

Code: Select all

    // Begin Precise Similar Topics
    $sql_array = array(
       'SELECT'   => 'u.user_id, u.username, f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_time, t.topic_last_post_time, 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'
          ),
         array(
             'FROM'   =>   array(USERS_TABLE   => 'u'),
             'ON'   => 'u.user_id = t.topic_last_poster_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_user = get_username_string('full', $similar['user_id'], $similar['username']);
             $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'],
                'U_TOPIC'                => $similar_topic_url,
                'TOPIC_LAST_TIME'        => $user->format_date($similar['topic_last_post_time']),
        'TOPIC_TIME'            => $user->format_date($similar['topic_time']),
        'USER'                => $similar_user,
                'U_FORUM'            => $similar_forum_url,
                'FORUM'               => $similar['forum_name'])
             );
          }
       }
    }
    // End Precise Similar Topics
 
Select the template block you just add:

Code: Select all

    <!-- IF .similar -->
        <br />
        <table class="tablebg" width="100%" cellspacing="1">
            <tr>
                 <th style="text-align: left;">Similar Topics</th>
            </tr>
            <tr><td class="row1">
                 <table width="100%">
                 <tr>
                    <!-- BEGIN similar -->
                    <td width="20%" valign="top"><div style="margin: 5px;"><a href="{similar.U_TOPIC}" class="topictitle">{similar.TOPIC_TITLE}</a><br />
                       {L_FORUM}: <a href="{similar.U_FORUM}">{similar.FORUM}</a></div>
                    </td>
                    <!-- END similar -->
                 </tr>
                 </table>
            </td></tr>
        </table>
        <!-- ENDIF -->     
 
Replace with:

Code: Select all

<!-- IF .similar -->
    <br />
    <table class="tablebg" width="100%" cellspacing="1">
        <tr>
             <th style="text-align: left;">Similar Topics</th>
        </tr>
        <tr><td class="row1">
             <table width="100%">
             <tr>
                <!-- BEGIN similar -->
                <td width="20%" valign="top"><div style="margin: 5px;"><a href="{similar.U_TOPIC}" class="topictitle">{similar.TOPIC_TITLE}</a><br />
                   {L_FORUM}: <a href="{similar.U_FORUM}">{similar.FORUM}</a><br />
                   {L_POSTED} {L_POSTED_ON_DATE}: {similar.TOPIC_TIME}<br />
                   {similar.USER} &raquo; {similar.TOPIC_LAST_TIME}
                   </div>
                </td>
                <!-- END similar -->
             </tr>
             </table>
        </td></tr>
    </table>
    <!-- ENDIF -->
 
Modify it the way you want, hope that works ;)
starstuff
Registered User
Posts: 58
Joined: Tue Mar 02, 2010 6:59 pm
Location: Germany

Re: [DEV] Precise Similar Topics

Post by starstuff »

Is anyone here working on a cache-solution?
Unfortunately my coding knowledge is very limited for this :(
Locked

Return to “[3.0.x] MODs in Development”