Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How To: search.cgi?catid=21&query= to return all links in the category?

Quote Reply
How To: search.cgi?catid=21&query= to return all links in the category?
  
How To: www.mysite/links/search.cgi?catid=21&query=

If the query is blank show all links in this category.

I want to show all links in 1) main category and subcategories and/or 2) all links subcategories if the query is blank (or query=* or query=all or something like that). Thanks!

Last edited by:

socrates: Feb 20, 2017, 9:46 PM
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

I could be wrong, but I'm pretty sure query=* would do the job.

I've actually hacked some of my own installs so that it doesn't stop the search if query is empty, and catid has a value.

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: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi Andy,

Thanks and good to see you but that query=* does not work and returns back to the search form - it does not work unless some input is provided to the query and works as long as even one letter is entered. By the way, I posted in your support forum regarding some errors about your plugins and hope you can help (whenever you can, if you are busy now) to get those errors fixed sometime. Thanks!
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

You could try editing /admin/User/Search.pm. Find:

Code:
return search() if defined $args->{query} and $args->{query} =~ /\S/;

and change to:

Code:
return search() if ((defined $args->{query} and $args->{query} =~ /\S/) || $args->{catid} =~ /^\d+$/);

I think that is all I changed on my install.

Quote:
By the way, I posted in your support forum regarding some errors about your plugins and hope you can help (whenever you can, if you are busy now) to get those errors fixed sometime. Thanks!

You may be better posting them here :) I have not looked at that forum for a long time, as no one uses it any more.

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: search.cgi?catid=21&query= to return all links in the category? In reply to
Thanks, will try that tomorrow and let you know.

With regards to issues with your plugins, can I send you a pm here or should I start a new thread in the forum here? For now pl. see my post in your forums for errors with regards to a couple of plugins I mentioned and see if you can fix them.

Last edited by:

socrates: Feb 21, 2017, 1:28 AM
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

Either on the forum, or you can email me on andy@ultranerds.co.uk. I don't like using PM's, as they are so hard to keep track of Whistle

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: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi Andy,

The above fix for search results works fine now without need to enter any query. However, would it be possible to go one step further and make it so when a Category Name is entered it will look up for the catid and then do the search ie. /search.cgi?CatName=Automotive&query=

There are a couple of subs in search.pm that match the categoryname to the corresponding catid and I don't know if they could be used to get the category name. In the above example it will get the proper catid for Automotive and then get all the links in that category (of course, as earlier if the query is blank then it will get all the links and if there is a query then it will only return matching links). Thanks!
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

Thats a bit trickier. You could try this code:

Code:
if ($args->{catname}) {
my $catid = $DB->table("Category")->select( ['ID'], { Name => $args->{catname} })->fetchrow;
if ($catid =~ /^\d+$/) {
$args->{catid} = $catid
}
}

It will only work for top level categories though.

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: search.cgi?catid=21&query= to return all links in the category? In reply to
Thanks Andy, I had tried something similar to the above except I did not have a if loop in between. I put the above code just above the previous code. Anyway, with the above code (and what I tried earlier) returns all links in the database ie. it prints all the links in the database regardless of the catname input value but if I don't enter any catname it will revert back to the search form meaning, when a catname is provided it seems to be looking up for the corresponding catid but prints out all links. If you do come up with a solution later, please do let me know.Thanks!
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

Are you saying that if you pass a category name along, it loads the results, but seems to load ALL results? (not just those in the given category)

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: search.cgi?catid=21&query= to return all links in the category? In reply to
Yes, if you pass catname=thenameofthecategory it loads all links in the search results and not just links in that category. Thanks!
Quote Reply
Re: [socrates] How To: search.cgi?catid=21&query= to return all links in the category? In reply to
Hi,

OK, I think I see the issue. search() actually grav $IN->get_hash again, thus ignoring the value we overwrote. So try:

Code:
if ($args->{catname}) {
my $catid = $DB->table("Category")->select( ['ID'], { Name => $args->{catname} })->fetchrow;
if ($catid =~ /^\d+$/) {
$args->{catid} = $catid;
$IN->param('catid' => $catid);
}
}

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!