View Single Post
  #3  
Old 04-03-2015, 03:14 AM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01534 seconds
  • Memory Usage 1,796KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete