Announcement

Collapse
No announcement yet.

Similar threads, show more than 5 results?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Similar threads, show more than 5 results?

    As the title sums it up I'm looking for a way to make the similar threads option that shows up on the bottom of every thread display more than 5 results. I spent over 1 hour looking for it in the admin panel (even searching for "similar" and looking through those results to no avail).

  • #2
    Any ideas?

    Comment


    • #3
      Looks like it's hard-coded in includes/functions_search.php around line #467 where the query has a limit 5 on it
      Lats...

      Comment


      • #4
        ah ok nice find I'll try changing that after my server finishes upgrading & see what happens. I'm guessing this is the only way to change it. I changed it to 10 where you suggested and it still is displaying only 5 results as seen here http://vgchat.info/forum/f33-nes/sup...rt-7-6964.html (there are 6 parts to this movie only the default 5 similar links show.)

        Also there was another part in that file where the limit was set to 5 as well

        Code:
        // ###################### Start getsimilarthreads #######################
        function fetch_similar_threads($threadtitle, $threadid = 0)
        {
            global $vbulletin;
        
            if ($vbulletin->options['fulltextsearch'])
            {
                $hook_query_joins = $hook_query_where = '';
                $similarthreads = null;
        
                ($hook = vBulletinHook::fetch_hook('search_similarthreads_fulltext')) ? eval($hook) : false;
        
                if ($similarthreads !== null)
                {
                    return $similarthreads;
                }
        
                $similarthreads = '';
        
                $safetitle = $vbulletin->db->escape_string($threadtitle);
                $threads = $vbulletin->db->query_read_slave("
                    SELECT thread.threadid, MATCH(thread.title) AGAINST ('$safetitle') AS score
                    FROM " . TABLE_PREFIX . "thread AS thread
                    $hook_query_joins
                    WHERE MATCH(thread.title) AGAINST ('$safetitle')
                        AND thread.open <> 10
                        " . iif($threadid, " AND thread.threadid <> $threadid") . "
                        $hook_query_where
                    LIMIT 10
                ");
                while ($thread = $vbulletin->db->fetch_array($threads))
                {
                    // this is an arbitrary number but items less then 4 - 5 seem to be rather unrelated
                    if ($thread['score'] > 4)
                    {
                        $similarthreads .= ", $thread[threadid]";
                    }
                }
        
                $vbulletin->db->free_result($threads);
        
                return substr($similarthreads, 2);
            }
        
            // take out + and - because they have special meanings in a search
            $threadtitle = str_replace('+', ' ', $threadtitle);
            $threadtitle = str_replace('-', ' ', $threadtitle);
            $threadtitle = fetch_postindex_text(trim($threadtitle));
        
            $retval = getsearchposts($threadtitle, 0);
            if (!$retval OR sizeof($retval['scores']) == 0)
            {
                return '';
            }
        
            if (sizeof($retval['scores']) < 20000)
            {
                // this version seems to die on the sort when a lot of posts are return
                arsort($retval['scores']);    // biggest scores first
        
                foreach ($retval['scores'] AS $postid => $score)
                {
                    if (($score / $retval['searchables']) < $vbulletin->options['similarthreadthreshold'] OR $numposts >= $vbulletin->options['maxresults'])
                    {
                        break;
                    }
                    else
                    {
                        $similarposts .= ', ' . intval($postid);
                        $numposts++;
                    }
                }
            }
            else
            {
                $scorelist = array();
                $postlist  = array();
                $maxarrsize = min(40, sizeof($retval['scores']));
                for ($i = 0; $i < $maxarrsize; $i++)
                {
                    $scorelist[$i] = -1;
                    $postlist[$i] = 0;
                }
                foreach ($retval['scores'] AS $postid => $score)
                {
                    if (($score / $retval['searchables']) < $vbulletin->options['similarthreadthreshold'])
                    {
                        continue;
                    }
                    $arraymin = min($scorelist);
                    if ($score > $arraymin)
                    {
                        $i = 0;
                        foreach ($scorelist AS $thisscore)
                        {
                            if ($thisscore == $arraymin)
                            {
                                $scorelist["$i"] = $score;
                                $postlist["$i"] = $postid;
                                break;
                            }
                            $i++;
                        }
                    }
                }
                foreach ($postlist AS $postid)
                {
                    if ($postid)
                    {
                        $numposts++;
                        $similarposts .= ', ' . intval($postid);
                    }
                }
            }
        
            if ($numposts == 0)
            {
                return '';
            }
        
            $sim = $vbulletin->db->query_read_slave("
                SELECT DISTINCT thread.threadid
                FROM " . TABLE_PREFIX . "post AS post
                INNER JOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = post.threadid)
                WHERE postid IN (0$similarposts) " . iif($threadid, " AND post.threadid <> $threadid") . "
                ORDER BY ($numposts - FIELD(post.postid $similarposts )) DESC
                LIMIT 10
            ");
            $similarthreads = '';
            while ($simthrd = $vbulletin->db->fetch_array($sim))
            {
                $similarthreads .= ", $simthrd[threadid]";
            }
            $vbulletin->db->free_result($sim);
        
            return substr($similarthreads, 2);
        }
        
        // #############################################################################
        Last edited by scylla22; Sun 17 Jan '10, 6:35pm.

        Comment


        • #5
          Is this the only way?

          Comment


          • #6
            You need to change it in a few places. First, where it defines the similar threads when you create the thread (that is the query you changed) and then where it spits out the list in the showthread.php page. Look in packages/vbdbsearch/coresearchcontroller.php for public get_similar_threads . That may be the other place you need to change (sorry, I'm still getting used to the vB4 code).

            Please don't PM or VM me for support - I only help out in the threads.
            vBulletin Manual & vBulletin 4.0 Code Documentation (API)
            Want help modifying your vbulletin forum? Head on over to vbulletin.org
            If I post CSS and you don't know where it goes, throw it into the additional.css template.

            W3Schools &lt;- awesome site for html/css help

            Comment


            • #7
              ? I'm asking how to do this in vbulletin 3.8.x

              Comment


              • #8
                Whoops, sorry. But yes, you will have to modify the query as Lats posted and then rerun the counters for similar threads if you want all older threads to be filled with more threadids.

                Did you check your database to see if the similar column in the thread table now has more threadids? Are you positive that when you ran the update counters that it did all the threads?

                Please don't PM or VM me for support - I only help out in the threads.
                vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                Want help modifying your vbulletin forum? Head on over to vbulletin.org
                If I post CSS and you don't know where it goes, throw it into the additional.css template.

                W3Schools &lt;- awesome site for html/css help

                Comment


                • #9
                  Well you see I undid the edit listed above due to plugins at vb.org so it got undone and this time I want to make sure for certain that this would be the right way to add more results to similar threads at the bottom of every thread.

                  Comment


                  • #10
                    Did you try a search before posting this thread? I know this whole issue was discussed before and the changes to make to the files were posted.

                    Please don't PM or VM me for support - I only help out in the threads.
                    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                    Want help modifying your vbulletin forum? Head on over to vbulletin.org
                    If I post CSS and you don't know where it goes, throw it into the additional.css template.

                    W3Schools &lt;- awesome site for html/css help

                    Comment


                    • #12
                      I just did the change above on my test site and it worked just fine *except* I did have to change the database to accomodate more threadids in that field. I edited the similar field in the thread table and changed it from varchar(55) to varchar(110). After I updated the counters, I then had 10 similar threads listed.

                      Please don't PM or VM me for support - I only help out in the threads.
                      vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                      Want help modifying your vbulletin forum? Head on over to vbulletin.org
                      If I post CSS and you don't know where it goes, throw it into the additional.css template.

                      W3Schools &lt;- awesome site for html/css help

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X