Thank you kh99 for your reply.
Yes I want articles with most tags in common, and yes I have a reason for choosing only display articles that published before the one that user read it in that time, and the reason so simple and logically, I used the CMS as news platform on my site, and with this feature I can make stories linked to each other and I can let users stays more time in my site by traveling form one article to another to understand the story exactly and clearly, but if I display the articles published after the one the user is reading the chain of articles will be broken and the misunderstand may be happened, even that I have another reason (Technically one) if I will show new articles too, that means I have to run the check for that article every time new article published in my site, but the logic said I have to do this only when add article or edit it (including add and delete tags).
Any way, I still waiting for someone to help me to make this feature available
Thanks.
--------------- Added [DATE]1428120755[/DATE] at [TIME]1428120755[/TIME] ---------------
Any ideas?
By the way here is the function that do the most work of similar threads
PHP Code:
public function get_similar_threads($threadtitle, $threadid = 0)
{
global $vbulletin;
//we'll leave the join stuff in from the existing hook, though its
//likely to break any existing code because we've changed the query
$hook_query_joins = $hook_query_where = '';
$similarthreads = null;
($hook = vBulletinHook::fetch_hook('search_similarthreads_fulltext')) ? eval($hook) : false;
if ($similarthreads !== null)
{
return $similarthreads;
}
$contenttypeid = vB_Types::instance()->getContentTypeID('vBForum_Thread');
$safetitle = $vbulletin->db->escape_string($threadtitle);
$threads = $vbulletin->db->query_read_slave("
SELECT searchgroup.groupid, MATCH(searchgroup_text.title) AGAINST ('$safetitle') AS score
FROM " . TABLE_PREFIX . "searchgroup AS searchgroup JOIN " . TABLE_PREFIX . "searchgroup_text AS searchgroup_text ON
(searchgroup.searchgroupid = searchgroup_text.searchgroupid)
$hook_query_joins
WHERE MATCH(searchgroup_text.title) AGAINST ('$safetitle') AND
searchgroup.contenttypeid = $contenttypeid
" . ($threadid ? " AND searchgroup.groupid <> $threadid" : "") . "
$hook_query_where
HAVING score > 4
LIMIT 5
");
$similarthreads = array();
while ($thread = $vbulletin->db->fetch_array($threads))
{
$similarthreads[] = $thread['groupid'];
}
$vbulletin->db->free_result($threads);
return $similarthreads;
}
But the problem here is that I have x tags for every single article, so I don't get the best way to write the code without a lot of loops.
I wish some one can help in this.
Thanks in advance.