Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1259)
Highlight Search Keywords 1.24 by Nathaniel
Formerly by Kalbenson. (http://custom.simplemachines.org/mods/index.php?action=search;author=63186)
OverviewThis mod allows you to customize the colors that you use for your search highlighting within the smf system. Its a very simple mod but a useful one because it means that you can get rid of the monotone default yellow highlighting which comes with SMF.
You can find the settings for the Mod at this locations for both versions of SMF.
'Admin' Section -> 'Forum' Subsection -> 'Search' settings area -> 'Highlight Search Keywords' tab.
If you don't set any colors in the admin settings area then this mod will make no difference to your actual highlighting, because it will automatically highlight the keywords with the default SMF yellow (color code: 'FFFF00').
SMF Version SupportThis mod is officially supported for SMF 2.0 final and above only. Below is a list of available versions of this mod and the previous versions of SMF that they supported. Use them at your own risk. The mod author will not be supporting or upgrading this mod in any way for versions of SMF below 2.0 final.
Version 1.23: SMF 1.1.x and versions of SMF 2 before SMF 2 RC3.
Version 1.24: SMF 2 RC3 and above.
DonateIf this mod has helped you, then feel free to support the developer by
Donating (https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VCFQ7MJNVXLLA&lc=AU&item_name=Donation¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted). Any amount of money is welcome.
Version Changesv1.24 - 27 May 2010
Changed package info to work with SMF 2 RC3.
Removed official support for SMF versions below SMF 2 RC2.
Updated the Search template edits for SMF 2 RC3.
v1.23 - 19 Novermber 2009
Updated for SMF 2 RC2 compatibility.
v1.22 - 18 August 2009
Updated mod for SMF 1.1.10 compatibility - Added a workaround for the SMF version bug.
v1.21 - 12 September 2008
Updated Mod for SMF 2 Beta 4.0 and SMF 1.1.6.
v1.2 - 14 June 2008
Upgraded Mod for SMF 2 Beta.
Fixed some minor bugs.
Added a settings area to chose colors.
v1.1 - 7th January 2008
Changed some comma concenators to dots
v1.0 - 4th January 2008
Initial Release
Version 1.21 - 12 September 2008
Updated Mod for SMF 2 Beta 4.0 and SMF 1.1.6.
I already have the mod installed, but I was trying to look into the code to see if I could modify how it highlights the search terms.
On my site, due to the colorings, using a highlighted box around the search word does not work well.
I would much rather highlight the text itself instead.
Search for this code (Subs.php and Search.php):
<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>
Replace with this code:
<span style=\"color:".$color.";font-weight:bold;\">\$1</span>
That worked for when a user clicks the subject in the search results and goes to the topic. In the topic, the search words text are a different color.
But on the =search2 page (the search results), the highlight is still a box around the text.
EDIT OPPS :P
I must have not saves the edit in Search.php
THANK YOU!!
It works well and looks GREAT!!
Just what I was looking for.
One of the things I added to my search2 page, is a header that shows what words the user has searched for.
I reused a part of the code found in the "did you mean" search form (in search.template.php) in order to get the searched words to show up.
Anyway, I would like to get the Highlight Search Keywords coding to highlight this heading, that way the user has a reference for what word is what color.
I have tried and tried for hours to get this mod to pick up on this simple header, but it has beaten me. I don't know how to do it and I could use your help, please.
Below is the code I hacked from the form to create this custom header I'm talking about
(use at your own risk everyone, even though it works, it is a total hack)
<td class="metal_plate_top_center">
<span style="font-size: 70%;"><i>', $txt['you_searched_for'] ,':</i></span> ', $context['search_params']['search'], '
</td>
... and for a peek at this code in action, click here [LINK] (http://redneckfabrication.com/index.php?action=search) and search for something.
This code shows up on the next page (search2) at the top center of the second metal plaque.
You should simply be able to call the 'highlighter' function, like in the code below.
<td class="metal_plate_top_center">
<span style="font-size: 70%;"><i>', $txt['you_searched_for'] ,':</i></span> ', highlighter($context['search_params']['search']), '
</td>
I think I just learned something ;D
So what do I call that, when you put do the highlighter( ) thing?
Thanks a lot!!
That didn't work.
The text shows up, but there's no highlighting/color change.
I have 1.21 installed but I cannot either uninstall the previous version nor the new version can upgrade the old one!! Any suggestion?
Please disregard. I fixed it. Great update and thank you.
Quote from: ∑£ℓ¢†®¡¢ §ợų¡đ on September 15, 2009, 09:25:44 PM
That didn't work.
The text shows up, but there's no highlighting/color change.
Yea, disregard mine too.
I'm moving on to SMF 2.0, and with it, the theme I needed this added coding for will be redone.
Thanks for your help with making the text (font) color change instead of the highlight box around it.
It looks so much better that way, and I will be looking to use that tweak again when I get SMF 2.0 up and running.
:D I just checked to see if you coded for 2.0 too
Thanks, it looks like you are keeping up with the progression of SMF!!
v1.23
Updated for SMF 2 RC2 compatibility.
in forum Turkish "I" letter write a blank page when
Quote from: karanima on January 01, 2010, 10:29:25 AM
in forum Turkish "I" letter write a blank page when
Could you please try to reword your post/explain your issue differently? I am not sure what you mean.
search "ı" letters white page
turkish forum
ı don't speak english sorry.thank google translate :)
Will this be updated to work with 1.1.11? Thanks. :)
Nice Mod
Please update it for SMF 2.0RC3 ;)
Thanks
Hello!
An update to SMF 2.0rc3 is provided?
v1.24 - 27 May 2010
Changed package info to work with SMF 2 RC3.
Removed official support for SMF versions below SMF 2 RC2.
Updated the Search template edits for SMF 2 RC3.
works like a charm on 1.1.14 (v1.23 of the mod)
thanks for this really nice mod! :)
Thank you for the wonderful mod! I thought I'd let everybody know that when I updated my forum from 2.0 RC5 to 2.0 Gold, I had to reinstall all my mods. This mod installed without issues and without emulation. Hope this info helps someone!
Nice thanks confirm 2 gold np on install ;)
Also confirmed that this mod works for SMF 2.0 gold. Thanks for the feedback. :)
Hello,
At first, thank you for this great mod, which worked perfectly until now on SMF 2.11 before migrating on PHP 5.5
With PHP 5.5 we have many deprecated errors #8192 reported in log, more than 1000 per day, due code of this mod in "search.php" and "Subs.php":
Quote8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
Fichier: .../htdocs/forum/Sources/Search.php
Ligne: 2115
and
Quote8192: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
Fichier: .../htdocs/forum/Sources/Subs.php
Ligne: 4583
I tried to fix it, but, I can not, because I'm not a php developer:
For exemple in subs.php at 4583 there are:
$message = preg_replace('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''),
"'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'",
$message);
I tried unsuccessfully this change:
$message =
preg_replace_callback(
'/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')' . ($context['utf8'] ? 'u' : ''),
//"'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'",
function ($m) {
return "'$m[2]' == '$m[1]' ? stripslashes($m[1]') : '<span style=\"background-color:".$color.";font-weight:bold;\">$m[1]</span>'"
},
$message);
I think that i have bad syntax in the second parameter , so I have changed it like this:
return ($m[2].' == '.$m[1].' ? stripslashes('.$m[1].') : <span style=\"background-color:".$color.";font-weight:bold;\">'.$m[1].'</span>')
but this is the same situation, in twice, my changes have blocked my forum.
At this time, i can only delete logs at each time, any help was welcome
Than you
I did these changes to get it working on new versions of PHP
Subs.php
Find
$message = preg_replace('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"background-color:".$color.";font-weight:bold;\">\$1</span>'", $message);
Replace with
$context['highlight_color'] = $color;
$message = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), 'highlightmod__preg_callback', $message);
End of Sources/Subs.php
Add
function highlightmod__preg_callback($matches)
{
global $context;
return isset($matches[2]) && $matches[2] == $matches[1] ? stripslashes($matches[1]) : '<span style="background-color:' . $context['highlight_color'] . ';font-weight:bold;">' . $matches[1] . '</span>';
}