Gossamer Forum
Home : Products : Links 2.0 : Customization :

New Mod? - Live Search

Quote Reply
New Mod? - Live Search
Live Search Mod - with SSI and Javascript - for templates.

This modification allows you to build a live search like the "Live Search" by http://www.fireball.de.
It displays the last X search terms with a Javascript ticker on a .shtml page.
The mod logs the last X search terms and dispaly them "live".

The mod could be download at: http://www.simball.de/links_mods/

Comments or questions are welcome.

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Re: New Mod? - Live Search In reply to
I tried the Search Result Mod but it gave me an Unkown Tag: $resultout error in search_results.html when I searched

Gene
Quote Reply
Re: New Mod? - Live Search In reply to
Oh Gene,
i forgot something to say. Blush

In site_html_templates.pl in sub site_html_search_results add:
Code:
resultout => $resultout;
above:
Code:
%in,
Hope that work's. Wink

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Re: New Mod? - Live Search In reply to
Hi:

Great mod! Couple points:

1. The JS will error if a surfer includes quotations (") in the search term - for example, "perl scripts". I suggest removing them via regexp in livesearch sub:

$searchterm =~ s/"//gi;

There may be others to remove like back (escape) slashes. You could remove all non-word characters but this may be too restrictive as some are used in some cases.

2. You should omit duplicate entries in the jslivesearch.txt log file:

if(-e $datafile) {
open (DATA, "$datafile");
if ($useflock == 1) { flock (DATA, 2); }
@data = <DATA>;
if ($useflock == 1) { flock (DATA, 8); }
close(DATA);
if (grep (/^$searchterm/, @data)) { return; }
}



Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: New Mod? - Live Search In reply to
Hmm Dan,
in sub livesearch I have following line:
Code:
$line =~ s/["'!;.,#*+~]+//g;
I think this delete quotations?! For me it works.

For example search for:
Code:
http://www.fussballsuche.de/cgi-bin/suchen.cgi?query="soccer"
and try then http://www.fussballsuche.de/livesearch.shtml - the last search term will be 'soccer' and no Javascript Error will be displayed. Wink

Thank's for pointing out the second hint. I'll be implementate it. Cool

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Re: New Mod? - Live Search In reply to
Hi:

I missed that Blush - too late to be doing this. But depending on the value of $maxterms and the size of the jslivesearch.txt file, it may be better to clean the search term before you log it - instead of using the foreach loop. The number of logged terms can be assessed via: $lines = @data;

BTW, you may want to make the grep search case-insensitive.


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: New Mod? - Live Search In reply to
yep, already tried that. Same results. Any ideas? I must have done something wrong.

Do you mean

resultout => $resultout,

instead of

resultout => $resultout;

????

And I copied and pasted to avoid typing errors.

Gene
Quote Reply
Re: New Mod? - Live Search In reply to
Yes it should be , not ;

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: New Mod? - Live Search In reply to
Sorry for my horrible mistake. Blush
You're rigth Glenn.

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Re: New Mod? - Live Search In reply to
LOL....Gene....not Glenn! Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: New Mod? - Live Search In reply to
just haven't had time to go back to this but i had already made the correction you suggested and I'm still getting the tag not found error.

and not a horrible mistake. It is very easy to think it was glennu since he helps a lot.

Gene
Quote Reply
Re: New Mod? - Live Search In reply to
I installed the live search mod I have one problem with it
I get this message in my source code ..
var text = new Array([an error occurred while processing this directive]);

I installed it a few times changed directories but it keeps givving this message..
What am i doing wrong??

regards alfred


regards
alfred
Quote Reply
Re: New Mod? - Live Search In reply to
Hi Alfred:

Assuming you correctly installed the mod (did you call the jslivesearch.pl script from the browser to test?), use relative instead of absolute URL in the SSI tag in the JS. Otherwise, what do your server error logs tell you?


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: New Mod? - Live Search In reply to
Hi Alfred:

Assuming you correctly installed the mod (did you call the jslivesearch.pl script from the browser to test?), use relative instead of absolute URL in the SSI tag in the JS. Otherwise, what do your server error logs tell you?

Yes i called it from my browser. It's been called from the js that's added in the head of home.html.

I tryed the absolute path and the relative path. but it still gives the same.

Im not that advandced that i know what kind off error there is in the server log..
But it seems that There is a problem in this js thats in the head the code is as follows


<script language="JavaScript">

</script>

When i run the livesearch.pl from the browser http://virtualshowroom.virtualave.net/links/jslivesearch.pl
It's working it shows the saved search results.
the url is the same in the js but doesnt work there

regards alfred


regards
alfred
Quote Reply
Re: New Mod? - Live Search In reply to
Hi Alfred:

I pulled your page from your server and see you have:

var text = new Array(!--#include virtual="http://virtualshowroom.virtualave.net//links/jslivesearch.pl"--);

You're missing the opening and closing brackets in the SSI tag. Try the following:

Code:
var text = new Array([!--#include virtual="http://virtualshowroom.virtualave.net/links/jslivesearch.pl"--]);
And if that fails, try:

Code:
var text = new Array([!--#include virtual="/links/jslivesearch.pl"--]);
Replace in each case, [ and ] with the angular brackets - since this forum script removes them as HTML tags.


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: New Mod? - Live Search In reply to
thanks dan :<)( i added the same codes with the larger and smaller bracket. but some how i made a mistake i gues.)
Now it shows the saved searches in the sourcecode of home.html
The results don't show up in the form but i'll get to that.
ill try that myself first


regards alfred

regards
alfred
Quote Reply
Re: New Mod? - Live Search In reply to
i found it already
something not in the text file that goes along with it
but in the body tag there has to be a onload
like this: BODY onload="scroll();"
and the the rest off the body tag....
So than the saved searches will show in the form.....

So the mod works great


regards
alfred
Quote Reply
Re: New Mod? - Live Search In reply to
Hi Alfred:

Actually you are right. It's in the ZIP file but not in the mod page, or the instructions text file. But you should have perused all the files in the ZIP file. At any rate, you got it installed correctly now. Great work Smile


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: New Mod? - Live Search In reply to
Thank's Alfred and Dan for pointing that out. Smile

The mod instruction page and the instruction file in the .ZIP file are updated. Wink

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Re: New Mod? - Live Search In reply to
Andy, *ups* the next mistake. Wink
Correction: Glenn => Gene

DelPierro
http://www.simball.de/links_mods/