Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to do command line search by category name instead of catid?

Quote Reply
How to do command line search by category name instead of catid?
I want to hardcode some search links and I want to make links to be searched only in a specific category.

Instead of specifying catid to search in only a specific category I want to specify the actual category names (because when you have a lot of categories it is easier to specify a category name instead of looking for the corresponding catid).

e.g. instead of using:

/search.cgi?d=1&catid=6&query=business&Go=Go

I would like to use:

/search.cgi?d=1&categoryname=Industries&query=business&Go=Go

Is this possible if so what is the correct variable for the category name?

thanks

Last edited by:

socrates: Dec 12, 2005, 11:34 PM
Quote Reply
Re: [socrates] How to do command line search by category name instead of catid? In reply to
Hi,

You would probably need a custom global, to go through and grab the value from "categoryname", and then do something like;

Code:
my $catid = $DB->table('Category')->select( ['ID'], { Full_Name => $IN->param('categoryname') } )->fetchrow || 0;
$IN->param( 'catid' => $catid );

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 do command line search by category name instead of catid? In reply to
Andy,

Is there anything more to it or that's it? That does not work from command line but I haven't tried it a a hardcoded link.

Thanks
Quote Reply
Re: [socrates] How to do command line search by category name instead of catid? In reply to
Erm, why are you trying to do this via command line?

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 do command line search by category name instead of catid? In reply to
Andy,

It doesn't have to be command line if it can work as a hardcoded link on a page. I am doing this because I would like to pull results from the links database to display on other pages of the site which have similar categories. Say, I have a page related to industries (somewhere else on my site), I want to be able to search for related links in the Industries category of links database and pull those results - like

search.cgi?d=1&category=Industries&query=business

I appreciate your help.

Last edited by:

socrates: Dec 14, 2005, 3:15 PM
Quote Reply
Re: [socrates] How to do command line search by category name instead of catid? In reply to
Andy,

When I say command line I actually mean from searching the brower bar.

Any ideas? I don't need to put anything in the templates - right?

Thanks
Quote Reply
Re: [Andy] How to do command line search by category name instead of catid? In reply to
Hi,

I grabed the custom global ==> categoryname

----------------------------------
sub {
my $catid = $DB->table('Category')->select( ['ID'], { Full_Name => $IN->param('categoryname') } )->fetchrow || 0;
$IN->param( 'catid' => $catid );
}
----------------------------------

But this was the result:

ARRAY(0x97032b8)


What am I doing wrong ? Thanks in advance.

JoseML
Quote Reply
Re: [JoseML] How to do command line search by category name instead of catid? In reply to
Hi,

Try adding;

return;

just before the closing }

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 do command line search by category name instead of catid? In reply to
Andy, thank you very much.

joseML