Gossamer Forum
Home : Products : Links 2.0 : Customization :

Search.cgi: Different Format Views

Quote Reply
Search.cgi: Different Format Views
I have modded search.cgi to produce two different formats (titles and titles and summaries) based on users selecting options in the advanced search form.

What I would like to do is add buttons or links in the result pages that will take them to other format (title of titles and summaries).

I have added the following codes in search.cgi:

Code:
$format_url = $ENV{'QUERY_STRING'};
$format_url =~ s/\&format=\//;

above where the links are put into results.

And then I added the following codes in the $link_results section:

Code:
$link_results .= qq|<br><a href="$build_search_url?$format_url&format=title"><img src="/images/search/hide.gif" alt="Hide Summaries" width="142" height="21" border="0"></a><P>|;

I am trying to mimic the process that occurs with the newhits (nh) routine by taking out the format argument from the query string and then re-add it with the correct format (titles or titles and summaries).

Any ideas about what I can to do to put a link or button in the search results to go to other format while maintaining the query string, please let me know.

Thanks.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Search.cgi: Different Format Views In reply to
doesn't search.cgi already have

Code:
$query = $ENV{'SCRIPT_NAME'};

?

just add the s/\&format=\w+//; thing below it.. using query of course..

that's how i sorta was able to maintain the sorting/ascending and descending for my categories and searches...

btw.. i would like to introduce something to you..

http://www.pdamania.com/sql/category.cgi

it's a really simple version of a SQL directory.. (all text based.. lol)

just FYI.. accessories has subcats.. accessories/modem has one.. and then test category has links.. all sql.. (i am gonna add some more features.. it has an admin.. just not a user add yet Smile)

jerry

[This message has been edited by widgetz (edited September 18, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Very nice script, Jerry.

The regular expression for the format variable worked.

There is no $query = $ENV{'SCRIPT_NAME'}; in search.cgi.

What I did was add the regular expression you gave me after the following codes:

Code:
$format_url = $ENV{'QUERY_STRING'};

Works very nice.

Thanks. Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 18, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
BTW: Jerry, I adapted your category search to my main search form, like lycos.com.

Check it out at when you get chance:

www.anthrotech.com/cgibin/wwwvl/search.cgi

Thanks again.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Search.cgi: Different Format Views In reply to
very nice eliot.. makes it look real cool.. (also.. linking it was smart Wink)

what about subcategories?

jerry
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Bmxer,

Nope. Haven't tried it. I am uploading the new search.cgi file as I am typing. Let's see if it works....Nope.

Well, the problem could be with the bolding results. I know that when I added the exact search mod, I had to change the bolding search routine.

Here is what I have for the bolding search routine:

Code:
if ($in{'case'} eq '1') {
$link_results=
~s,(<[^>]+> )|(\b\Q$term\E\b),defined($1) ? $1 : "<STRONG>$2</STRONG>",gie;
$category_results =~ s,(<[^>]+> )|(\b\Q$term\E\b),defined($1) ? $1 : "<STRONG>$2</STRONG>",gie;
}
if ($in{'case'} eq '2') {
$link_results=
~s,(<[^>]+> )|(\b\Q$term\E\b),defined($1) ? $1 : "<STRONG>$2</STRONG>",gie;
$category_results =~ s,(<[^>]+> )|(\b\Q$term\E\b),defined($1) ? $1 : "<STRONG>$2</STRONG>",gie;
}

Also, Jerry, I did try the codes you gave and they did not make any difference.

Any ideas?

Thanks.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 19, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
i think it's a matter of editing these two lines:

$tmp .= "m/\Q${$search_terms}[$_]\E/io &#0124; &#0124;";

and

$tmp .= "m/\Q${$search_terms}[$_]\E/io &&";

you can just do..

Code:
($in{'case'}) ?
$tmp .= "m/\Q${$search_terms}[$_]\E/o &#0124; &#0124;" :
$tmp .= "m/\Q${$search_terms}[$_]\E/io &#0124; &#0124;";

and pretty much the same for the other one..
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Nope...Still didn't work.

Hmmm....

Thanks, Jerry.

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Jerry,

Thanks for the tip about the news mods. That may be the best place to start for date search.

Yes...the Case Setting would allow users to specify either Case Insensitive or CASE sensitive.

The codes I have so far for case sensitive are the following:

Code:
($in{'case'} eq '1') ?
($search_terms =~ tr/+/ /) :
($search_terms=lc($in{'query'}));

($in{'case'} eq '2') ?
($search_terms =~ tr/+/ /) : ($search_terms=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg);

I tried replacing $search_terms with @search_terms, but I got a special use of array not specified error. I also replaced $search_terms with $terms. I also replaced it with $in{'query'}. And nothing seems to work very well. It still searches by case insensitive.

I think that I may need to add in some more codes in the sub search routine in the search.cgi file.

If you have any ideas or suggestions for implementing this option, let me know.

Thanks in advance.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 19, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
i was also trying something like this, have you done it with ${$search_terms}[$_],
-----------------------
I just tried your code with my suggestion and i don't see it going by lowercase but i search one query with case=1 and 3 came back and then again with case=2 and 1 came back. The query was Lk;dj+and+oreilly, i'm still modifying Smile, anyway, the 3 came back because they all had lk;dj in the description but case2 had one come back because only one of the 3 has oreilly, so I think you just made links searching alot better.

[This message has been edited by Bmxer (edited September 19, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
I thought about using the codes you gave for using drop-down menus for sub-categories. However, I do not want to overwhelm web visitors with too many options. Wink

The next two things I am working on are the following:

1) Case Settings - currently in the form but not working. I am close, but not there yet.

2) By Date - web visitors can choose a number of days/months/years and get results of links added during those time periods. Hopefully later on, I can use LWP to get the modified dates of resources in my directory and search by those.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 19, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
doing by date is actually quite simple isn't it? those are great mods.. especially for a news archive of some sort..

also.. what do you mean by case settings?

like.. regular search is not case sensitive and then there is a case sensitive search?

that is a matter of adding and i after something like this

$field =~ m,$term,i;

jerry
Quote Reply
Re: Search.cgi: Different Format Views In reply to
does it not change or does it give you internal 500.

if internal 500.. that's cause you've got to make it so the &#0124; &#0124; are closed..

but i don't see why that wouldn't work.. that is what is being used to search...

and the i means case sensitive..

jerry
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Yep, I did close the | characters. And nothing new happens.

Thanks though.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Search.cgi: Different Format Views In reply to
Eliot,

Would it be possible to get the mod you created to show/hide summaries?

Thanks!
Adam Smile

[This message has been edited by anr (edited December 31, 1999).]
Quote Reply
Re: Search.cgi: Different Format Views In reply to
May be next year. Wink

Possibly in a week or two. I am in the midst of transferring my LINKS based site to a sub-domain, which has been more challenging than I anticipated because my ISP has disallowed me access to the .htaccess file to make appropriate changes to the sub-domain to make it function like the old site.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Search.cgi: Different Format Views In reply to
That's cool.

Good luck on transfering! and Happy New Year!

Adam Smile