Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to get the search parameters in search_results?

Quote Reply
How to get the search parameters in search_results?
I want to change the sorting in search_results with a single link (wihout a new form !) Therefor I need ALL search parameters,
the user had used before, for example:

search.cgi?query=magic&type=Picture&type=Link&ZIP=90210&bool=or&substring=0

Now I want to make a link like that:

search.cgi?<%SEARCH-PARAMETERS%>&sb=ZIP&so=DESC

I payed arround with <%GT::Template::dump%>, but I didn't find anything how to extract the seach parameters?

Anyone has an idea?

Thanks a lot,
Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
Hi,

There are quite a few =)

bool - boolean
nh - page
mh - max hits
substring - 1 or 0, depending if you want to search by substring
so - sort order (asc or desc)
sb - sort by (field)

You can also do stuff like:

Price-gt=500 , which would search for entries with the field value of GREATER than 500.
Price-lt=500 , which would search for entries with the field value of LESS than 500.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Hi Andy,

thanks, I know what they are, but I want to detect, which are used?

Do I have to write some code for all like:

search.cgi?query=<%query%><%if substring%>&substring=<%substring %><%endif%> ...

Isn't there an better way?

Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
Hi,

You could use a global;

Code:
sub {

my $back;
my @fields = split / /, q|query bool nh mh substring so sb|;
foreach (@fields) {
if ($IN->param($_)) {
$back .= qq|$_=| . $IN->param($_) . q|&|;
}
}
return $CFG->{db_cgi_url} . "/search.cgi?" . $back;
}

Call with just <%global_name%>

Totally untested (just wrote it now =)), but I don't see why it wouldn't work.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Great !!!

Thanks a lot, that easy to implemet and I have a singel point to modify.

Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Another question with that:

I have on parameter more than once to do a filter on several types (called Art):

http://www.guxme.de/...auberer&bool=and

Your script only uses the last value for Art, in this case Art=Grund, how can it use mor than one value for a parameter?


Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
Hi,

Glad it worked :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
cwschroeder wrote:
Another question with that:

I have on parameter more than once to do a filter on several types (called Art):

http://www.guxme.de/...auberer&bool=and

Your script only uses the last value for Art, in this case Art=Grund, how can it use mor than one value for a parameter?


Chris
Hi,

Sorry, not sure what you mean. Are you on about these bits:

Art=Foto
Art=Standard
Art=Grund

?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Yes, I need

http://www.guxme.de/cgi-bin/li/search.cgi?query=zauberer&lang=de&Art=Foto&Art=Standard&Art=Grund&bool=and

instead of

http://www.guxme.de/cgi-bin/li/search.cgi?query=zauberer&lang=de&Art=Grund&bool=and&so=DESC&sb=Add_Date

back. So if a parameter comes 2 or 3 times, the output must use this also 2 or 3 times.

Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
Hi,


Mmm.. ok. Well, you would need to use something like:

Code:
sub {

my $back;
my @fields = split / /, q|query bool nh mh substring so sb Art|;
foreach (@fields) {
if ($IN->param($_)) {
if (ref $IN->param($_) eq "ARRAY") {
my @tmp = $IN->param($_);
foreach my $tmp (@tmp) {
$back .= qq|$_=| . $tmp . q|&|;
}
} else {
$back .= qq|$_=| . $IN->param($_) . q|&|;
}
}
}
return $CFG->{db_cgi_url} . "/search.cgi?" . $back;
}

Note, you need to edit this line:

my @fields = split / /, q|query bool nh mh substring so sb Art|;

...ie adding the other fields, i.e Art, etc.

Hope that helps (again, not tested =))

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Thanks for that,

but it does not work like before. I does not understand the line

if (ref $IN->param($_) eq "ARRAY") {

but I think the problem is there?

Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
Hi,

This should work: (did a test myself on one of my dev installations);

Code:
sub {

my $back;
my @fields = split / /, q|query bool nh mh substring so sb Art|;
foreach (@fields) {
if ($IN->param($_)) {

my @array = $IN->param($_);

if ($array[1]) {

my @tmp = $IN->param($_);
foreach my $tmp (@tmp) {
$back .= qq|$_=| . $tmp . q|&|;
}

} else {
$back .= qq|$_=| . $IN->param($_) . q|&|;
}
}
}
return $CFG->{db_cgi_url} . "/search.cgi?" . $back;
}


Enjoy =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to get the search parameters in search_results? In reply to
Thats it !

Thanks a lot,
Chris
Thanks a lot for your help,
Christian

Quote Reply
Re: [cwschroeder] How to get the search parameters in search_results? In reply to
cwschroeder wrote:
Thats it !

Glad it works =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!