highlighting the keywords

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

Moderator: Moderators

highlighting the keywords

Postby talluri » Wed Dec 06, 2006 11:42 am

Hi,

As google search ,when we are entering some text in the google search box,some result will come.In that results if any keywords are matched with our text ,those keywords will be highlighted,I want code for that.In our application we are putting that one.Since two days I am trying for that.I dont have much knowledge in regular expressions.Can any one help me in this issue.It's very urgent to me.This is we are going to implement in forum itselft.While posting only I am checking for some keywords,if keywords matches only I am posting that one.So when we are seeing that topic that keywords should be highlighted.

Thanks,

Talluri. :(
talluri
 
Posts: 8
Joined: Thu Nov 23, 2006 7:32 am

Advertisement

Postby dcz » Wed Dec 06, 2006 12:48 pm

I am not sure to understand well here.

Are you saying you're not using phpBB and would like to add some highlight to your script ?
Or is it you want to reuse phpBB highlights somewhere ?

++
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

highlighting keywords

Postby talluri » Wed Dec 06, 2006 1:26 pm

Hi,

In our application we used phpbb only.In this we are having four categories.For each castegory we used some keywords,for tracking the post.Suppose the categories are
1.Romance
2.Classifieds
3.Jobs
4.Events

Suppose ,the user want to post one topic in romance,but instead he posted in classifieds,In that case we have to track that post based on some keywords(which are already in a data base) and we have to post in correct category.

When we are viewing that topic that kewords should be highlighted.

Regards,

Talluri
talluri
 
Posts: 8
Joined: Thu Nov 23, 2006 7:32 am

Postby dcz » Wed Dec 06, 2006 1:46 pm

But in case a user did not post in the correct forum, you can just move the topic, it won't change its URL, and will make it easier for user to browse the forums.

About the highlights, if this is correct, you want to highlight some of the post content.

So, this is rather easy, try these links :
http://phpbb2.phpbb-seo.net/phpbb-seo-d ... ight=phpBB
http://phpbb2.phpbb-seo.net/phpbb-seo-d ... =phpBB+SEO
The vanilla url would be :
http://phpbb2.phpbb-seo.net/viewtopic.p ... =phpBB+SEO

The highlight words are grabbed in viewtopic.php :
Code: Select all
//
// Was a highlight request part of the URI?
//
$highlight_match = $highlight = '';
if (isset($HTTP_GET_VARS['highlight']))
{
   // Split words and phrases
   $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));

   for($i = 0; $i < sizeof($words); $i++)
   {
      if (trim($words[$i]) != '')
      {
         $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
      }
   }
   unset($words);

   $highlight = urlencode($HTTP_GET_VARS['highlight']);
   $highlight_match = phpbb_rtrim($highlight_match, "\\");
}



As you can see, it's only waiting for GET vars, but you could easily add a check on post vars and get the highlights you want transmitted through POST var instead, sent from where the topic or post is linked, (since it seems you want to chooses them, the user does not need to see them in URL), so that you won't end up with any duplicates.

++
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 73 guests