HIGHLIGHT SEARCH KEYWORDS v1.1
By Karl Benson (http://custom.simplemachines.org/mods/index.php?action=search;author=63186)
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1051) | Support Topic (http://www.simplemachines.org/community/index.php?topic=215214.0) | Demo (http://www.adrevenueshare.com/index.php?topic=1.0;highlight=welcome+enjoy+simple+machines+please) | Donate (http://www.adrevenueshare.com/donate)
CompatibilityFor SMF 1.1.x ONLY.
IntroductionHighlights the search terms/keywords INSIDE the topic in Google-esc variety of colors.
Keywords called from the highlight={keywords} parameter added to links.
Changes the default 'yellow' highlighter in SMF Search to use this mods multicolored one.
Featureso Multi-colored highlighter
o Full & Partial word matches
o Keywords properly sanitized
o Prevents replacing any html
InstallationInstalls for SMF Default Core Theme and almost all other themes (except those with a custom Search.template.php [unlikely!])
There are NOT any language strings with this mod.
For themes other than the SMF Default Core Theme with a custom Search.template.php manual edits will be required.
Useful LinksSMF Package Parser (http://modparser.dev.dansoftaustralia.net/)
Manual Installation Of Mods (http://docs.simplemachines.org/index.php?topic=402)
How Do I Modify Files? (http://www.simplemachines.org/community/index.php?topic=24110.0)
DonateHas this modification helped you? Support the developer by
Donating (http://www.adrevenueshare.com/donate)
SupportPlease use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)
Changelog1.0 - 4th January 2008o Initial Release
1.1 - 7th January 2008o Changed some comma concenators to dots
Another excellent & useful mod!
No errors, installed fine.
can u explain a litlle bit more what is "google-esc" and why this is better for the forum? ... thx... sorry for noobish questions ^^
@Alejo.... everything is in the introduction and features... plus you are getting nice screen shots... if you use google and use the "cached" option then you'll see why is it "google-like" because the results are highlighted.
@Karl, great mod, as always!!! I have a question...
I installed the mod manually, no trouble at all, but I had to change the "," for "." like the ?topic=', $topic['id'] for example... and got curious... could you explain me why...
Quote<div class="quoteheader" style="margin-left: 20px;"><a href="'. $scripturl. '?topic='. $topic['id']. '.msg'. $message['id']. ';highlight='.$context['highlight'].'#msg'. $message['id']. '">'. $message['subject_highlighted']. '</a> '. $txt[525]. ' '. $message['member']['link']. '</div>';
Thanks again!
Strange.
Dots, join the string together before echoing, while Commas just send it to be echoed. (commas are therefore recommended to be used [where possible] because its faster)
Unless you got an error or issue, there shouldn't be a need to change the commas to dots.
The commas were actually are part of SMF's default code.
I got an error and my search.template when I tried the mod and it is full of dots, that's why I changed them.
Good to know then... thanks a lot!
let me try it thx
Another good mod from Karlbenson.
Hi
I have test this mod, wich is very interesting
but, like this:
Quote from: dannbass on January 07, 2008, 05:08:16 PM...I installed the mod manually, no trouble at all, but I had to change the "," for "." like the ?topic=', $topic['id'] for example... and got curious... could you explain me why...
I have the same, and search why:
in my case the problem is that I have installed before the mod : "DonationCoder.com SMF Search Enhancement Mod" , I have tested with an uninstall of it before, and mod Highlight run correctly.
After install mod "..SMF Search Enhancement Mod...", there are points, not comma in my search.template
I think the reason is that mod "...Search Enhancement..." is'nt conform with standardedit: I have just verifyed all, in fact, "...Search Enhancement..." use concatenation in a string variable ($str), and it is not echo function, in this case i suppose it's necessary to use point in place of comma
I have also maodify search.template manually, and yaour mod "Highlight Search Keywords" seems work properly.
"Sorry for my poor english, it is not my native language"@+
Bruno
Last night as a precautionary measure I replaced the commas in the string with dots.
1.1 - 7th January 2008
o Changed some comma concenators to dots
Yeah, Great mod! I tried making this mod, but failed =P lol. Looks great ;)
echo is a language construct and thus is why it doesn't need () around it. It also accepts unlimited amount of variables passed into it. Such as a function(arg1, arg2, arg3...). It will accept all of these. When using dots it has to join together all parts of an input before it can be sent to echo, commas I don't believe it waits and just sends it out. But from how fast php phrases the code anyways, you wouldn't notice a different. Besides being slightly faster we do this because it looks a bit nicer than all those dots.
You can't use commas in a string you are setting into a variable as well.
I have reuploaded this mod and screenshots for it.
I am in the process of doing it for ALL my other mods aswell. Please bear with me.
Is it safe to assume that if I want to change the 1st highlight color chosen (currently ffff66) all I would need to do is make the changes in Subs.php and Search.php? I can adjust the colors as needed in:
$colors = array('#ffff66', '#a0ffff', '#99ff99', '#ff9999', '#ff66ff', '#880000', '#00aa00', '#886800', '#004699', '#990099');
ETA: That did it. :)
Yeah it should work.
Note, I would NOT recommend ADDING more colors NOR REMOVING any colors.
This is because the colors have the id 0 - 9 representing the 1st to 10th colors.
If you have more keywords than that, it will use the last digit to work out what color to show.
So the 15th would take the 5th color etc
I removed the yellow and swapped it with a blue. The text in the forum is white and did not show very well with yellow highlight. So far no problems.
You have some great mods out there. Look forward to them in 2.0.
Hello Karl,
I installed this MOD but got error and my entire website is down. I uninstalled the MOD from Admin area and got error from removal.
What shall I do so that everything associated with this MOD I can remove manually and my site will be back without any code of this MOD? I have deleted the package in cPanel but there are codes in other php files that I don't know how to remove them manually.
Thanks for the advise.
I got this error every time I do a search in my site:
Fatal error: Call to undefined function: highlighter() in
/home/myaccount/public_html/mywebsite/Sources/Search.php on line 1575
The site is online again, only that search.php has errors caused by the "highlighter."
The function added by the mod is missing from Search.php
Use a package parser to get the function edit
http://www.adrevenueshare.com/parser
Double check all the edits of the mod.
Quote from: karlbenson on February 24, 2008, 10:43:28 PM
The function added by the mod is missing from Search.php
Use a package parser to get the function edit
http://www.adrevenueshare.com/parser
Double check all the edits of the mod.
Hello Karl,
I just want to remove the MOD and all its codes. I will install it next time.
My problem is that the search.php is already corrupted and causing ghost bumps in my website. Thank you, Karl.
Double check the edits and remove or add them as necessary.
Karl, can I just overwrite the search.php by uploading the search.php from my backup?
What are the files in SMF where I can remove trace of highlighter? I need to manually take them out as they are creating problems to my forum members.
It would depend whether any other mods are installed. I wouldn't recommending just replacing the search.php.
Like i said above, use the Package Parser to get the edits.
If you want to remove the mod manually, check that ALL the edits are removed in all the files.
Hello Karl,
I followed your instruction using the Parser.
For now, the site is running well. I just did the editing stuff.
Thank you, Karl!
Hi Karl,
I want to install this module but I am curious how will this help the forum. Will it help in search ranking or other things?
It won't help in terms of search rankings.
All it does it show users their search terms highlighted in the page (like Google does when you view its cache)
Hi Karl,
I got this error in my site after removing this MOD. I have done the Parser, but still the error shows up.
8: Undefined variable: body_highlighted
File: /home/mainfolder/public_html/subfolder/Sources/Search.php
Line: 1571
Undefined variable: subject_highlighted
File: /home/mainfolder/public_html/subfolder/Sources/Search.php
Line: 1572
Here's the code from search.php line 1571 to 1573. I'm not sure if get the right line.
$body_highlighted = preg_replace('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<b class=\"highlight\">\$1</b>'", $body_highlighted);
$subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/i' . ($context['utf8'] ? 'u' : ''), '<b class="highlight">$1</b>', $subject_highlighted);
}
Karlbenson is going to stop supporting this Mod and I am going to start supporting it, (http://www.simplemachines.org/community/index.php?topic=225192.0) I will look over the code in about two weeks and release another version of the Mod which supports SMF 2 Beta 3.1 and fixes any bugs that I can find, such as highlighting of the news bar when you open up an item which you have searched for and etc, or maybe a setting to turn that on or off.
I will probably also add a number of settings so that an admin can change some of the behaviors of this Mod, such as an extendable list of colors that will be used as well as a maybe a setting to turn the highlighting on or off.
Any comments or suggestions would be more than welcome in the next few weeks before I start the next version.
Thank you,
LHVWB