Uutiset:

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

Main Menu
Advertisement:

highlight the search keyword

Aloittaja yogesh_gamer, toukokuu 28, 2011, 12:22:29 AP

« edellinen - seuraava »

yogesh_gamer

how to highlight the search keyword
for example if i search the word "Prince" then it shouls highlight with color

Update:
i tried this mod:
http://custom.simplemachines.org/mods/index.php?mod=1259
but it change the background of that word.
i want to change the color of search keyword and makes it bold

yogesh_gamer

please reply me
its second day without any reply

Dzonny

Hello there.

You didnt specify what version of smf are you using?
I belive that you can manage what you need with mod that you tried with a bit of changes in Sources/Search.php, but the best would be to ask in mods support topic about that:
http://www.simplemachines.org/community/index.php?topic=244847.0

Regards.

Sir Osis of Liver


Hey, yogesh.  Not sure what you're asking.  Do you want to highlight the keyword in the Search input field?

When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

I am using 1.1.13 version.
I want to change the color of search keyword and make it bold.

Sir Osis of Liver


In index.template.php -

Find this:



<input type="text" name="search" value="" style="width: 190px;" />&nbsp;




Change it to this:



<input type="text" name="search" value="" style="width: 190px; color:red; font-weight:bold;" />&nbsp;

When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

#6
nothing happened

update:
hey its change the color of the word which we want to search

I want to change the color of search keyword in  the post.
I am poor in english.

update:
Just like this website. search "search" on this topic.
you will get what i wanted to say

Sir Osis of Liver


OK, I understand what you want.  It appears to be a standard feature of 2.0, but not 1.1.13.  Not a simple edit.  I may be able to modify the code of the mod you tried in your first post.  I'll have a look soon as I get some time.

When in Emor, do as the Snamors.
                              - D. Lister

Sir Osis of Liver

Didn't try this (don't like to install mods), but looks simple enough.

Reinstall the Highlight Search Keywords mod.

In /Sources/Subs.php -

Find this:



// Do the Highlight
$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);




Change it to this:



// Do the Highlight
$message = preg_replace('/((<[^>]*)|' . preg_quote(strtr($word, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<span style=\"color:".$color.";font-weight:bold;\">\$1</span>'", $message);



It should change the font color instead of the background, and make it bold, and create an admin option to set the color.

Let me know if it works.

When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

ok. i didn't find the text which is to be replaced
please help me

Sir Osis of Liver


You have to reinstall the mod first - the // Do the Highlight code is added to Subs.php by the mod, it's not in the original file.

When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

In actual i tried the mod on my another website (just for testing)
On my website when i apply the mod:
http://custom.simplemachines.org/mods/index.php?mod=1259

HighlightSearchKeywords_v1.23.tar.gz

i am getting this error (look 4th point)
nstalling this package will perform the following actions:
Type Action Description
1. Execute Modification ./Sources/Display.php Test successful
2. Execute Modification ./Sources/Subs.php Test successful
3. Execute Modification ./Sources/Search.php Test successful
4. Execute Modification ./Themes/default/Search.template.php [color=red]Test failed[/color]
5. Execute Modification ./Sources/ManageSearch.php Test successful
6. Execute Modification ./Themes/default/languages/Modifications.english.php Test successful
7. Execute Modification ./Themes/default/languages/Modifications.english-utf8.php Test successful



and when i tried

HightlightSearchKeywords_1.24.tar.gz

i am getting this error
LainaaThe package you tried to upload either is not a valid package or has become corrupted.

please reply me

Sir Osis of Liver


Thought you had installed that mod successfully.  Make sure it's uninstalled, and we'll try Plan B.

In style.css -

Find this:



/* Highlighted text - such as search results. */
.highlight
{
background-color: yellow;
font-weight: bold;
color: black;
}




Change it to this:



/* Highlighted text - such as search results. */
.highlight
{
font-weight: bold;
color: red;
}


When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

when i search a keyword.
its not showing effect.
in fact it just open the topic page simply.
without any search.
please register on my website and see.
website: www.downloadyourworld.com

Sir Osis of Liver


Just took a quick look at your site - no idea what it's doing.  The style.css edit works fine on my 1.1.13 install.  Did you uninstall the Highlight mod?  Any other mods installed?  What changes have you made to Search?

When in Emor, do as the Snamors.
                              - D. Lister


Sir Osis of Liver

#16
IIRC, you wanted Search to just display the topic, and that's what it's doing.  Can you attach your Search.template.php?

1.1.13 Search does not highlight anything in the topic subject line, only in the post description and post text, which you've eliminated with the earlier mod.  If you do some searches on your forum, you'll see that the search term is not always in the subject line, but rather in the post, which you're not showing, so there's nothing to highlight.  Can't have it both ways.

When in Emor, do as the Snamors.
                              - D. Lister

Sir Osis of Liver

#17

Here, look at this -



The previous mod eliminated the two lines with highlighted text, which are the post title and the post itself.  The topic subject line (circled in red) is not highlighted, and in many searches will not contain the keywords, so there's nothing to highlight.  Try searching 'Games' on your forum - you'll get a lot of topics that don't contain 'Games' in the subject, because Search found it in the posts, which are not displayed.

When in Emor, do as the Snamors.
                              - D. Lister

yogesh_gamer

I want to remove the screenshots from search page.
But when member open search result topic the search keyword should be red and bold.
just like vbulletin.

Sir Osis of Liver


Haven't been on a vB board for a while, and don't remember how their search works.  One of the coding boards I sometimes visit highlights all the matching keywords in the entire thread - it's hugely annoying. 

This may do what you want -

http://www.simplemachines.org/community/index.php?topic=215214.0;all

Looks like you should reinstall the original 1.1.13 Search.template.php before you try installing the mod.

When in Emor, do as the Snamors.
                              - D. Lister

Advertisement: