News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Highlight Search Keywords v1.1

Started by karlbenson, January 06, 2008, 09:24:16 PM

Previous topic - Next topic

karlbenson


HIGHLIGHT SEARCH KEYWORDS v1.1
By Karl Benson

Link to Mod | Support Topic | Demo | Donate

Compatibility
For SMF 1.1.x ONLY.

Introduction
Highlights 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.

Features
o Multi-colored highlighter
o Full & Partial word matches
o Keywords properly sanitized
o Prevents replacing any html

Installation
Installs 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 Links
SMF Package Parser
Manual Installation Of Mods
How Do I Modify Files?

Donate
Has this modification helped you? Support the developer by Donating

Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0 - 4th January 2008
o Initial Release
1.1 - 7th January 2008
o Changed some comma concenators to dots

Simplemachines Cowboy

Another excellent & useful mod!
No errors, installed fine.
My SMF forum: The Open Range

ALEJO

can u explain a litlle bit more what is "google-esc" and why this is better for the forum? ... thx... sorry for noobish questions ^^
solo el mas paranoico sobrevive

dannbass

@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!

karlbenson

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.

dannbass

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!

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Bulakbol

Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

btechnix

#8
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 standard

edit: 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

karlbenson

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

aldo

Yeah, Great mod! I tried making this mod, but failed =P lol. Looks great ;)

SleePy

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.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

karlbenson

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.

SgtMic

#13
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. :)
There is nothing more deadly than a US Marine and his rifle.
A close second is a US Marine and his K-BAR.
2/5 Fox Co.  (BlackHearts)
FAST Co. 5th Plt. (FIDO)

karlbenson

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

SgtMic

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.
There is nothing more deadly than a US Marine and his rifle.
A close second is a US Marine and his K-BAR.
2/5 Fox Co.  (BlackHearts)
FAST Co. 5th Plt. (FIDO)

humbleworld

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.

humbleworld

#17
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."

karlbenson

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.

humbleworld

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.

Advertisement: