Search Highlight PHPBB problem after mod rewrite

Discussions about the phpBB2 Forum. How to get the best from this powerful script.

Moderator: Moderators

Search Highlight PHPBB problem after mod rewrite

Postby sceltic » Tue May 09, 2006 1:15 am

I know that your mod pays attention to this issue

But at present a search resut on user seems to be pushing out urls that do not resolve

this sort of thing
Code: Select all
http://www.abc.com/phpbb2/post-4.html&highlight=#4
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Advertisement

Postby dcz » Tue May 09, 2006 7:56 am

hehe, now we have a real bug it seems, finally!

Well in fact not really, more something I forgot to handle, since it was a long time ago I deactivated highlights.

Actually this could be solved once and for all adding a Reg Ex in sessions.php, but I find it more efficient to do it directly in the php files.

The issue only appears when highlight=nothing.

I assume the link you posted here comes from search results so please try this :

Open :

Code: Select all
Search.php

Find :

Code: Select all
      $highlight_active = urlencode(trim($highlight_active));



after add :

Code: Select all
      $highlight_ok = ($highlight_active !='') ? "&highlight=$highlight_active" : '';


Find :
Code: Select all
         $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active");
         $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id'];



Replace with :

Code: Select all
         $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . $highlight_ok);
         $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . $highlight_ok) . '#' . $searchset[$i]['post_id'];


This will make sure no empty highlight will be parsed in search results urls.

But you can do as I did here, e.g get rid of the highlights once and for all.

To do so just comment this part of the search.php code :

Code: Select all
      $highlight_active = '';
      $highlight_match = array();
      for($j = 0; $j < count($split_search); $j++ )
      {
         $split_word = $split_search[$j];

         if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' )
         {
            $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is';
            $highlight_active .= " " . $split_word;

            for ($k = 0; $k < count($synonym_array); $k++)
            {
               list($replace_synonym, $match_synonym) = split(' ', trim(strtolower($synonym_array[$k])));

               if ( $replace_synonym == $split_word )
               {
                  $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is';
                  $highlight_active .= ' ' . $match_synonym;
               }
            }
         }
      }

      $highlight_active = urlencode(trim($highlight_active));



And change :

Code: Select all
         $forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']);
         $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&amp;highlight=$highlight_active");
         $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&amp;highlight=$highlight_active") . '#' . $searchset[$i]['post_id'];


To :

Code: Select all
         $forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']);
         $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] );
         $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] ) . '#' . $searchset[$i]['post_id'];


This a bit less user friendly, but in the end you are sure that no highlight duplicates (cause they are) will be posted ;) And there is Still the good old CTRL+F to highlight search terms ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB2 Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 43 guests