Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search Results Not Displaying All Categories

Quote Reply
Search Results Not Displaying All Categories
Whenever I do a search that has more than 25 categories, the search results will only list a maximum of 25 categories rather than listing all of them. So, if there are 35 categories that match the search criteria, I'm only getting 25 of them back, although the search results says that the search returned 35 categories. Is there anyway to change this to ensure that all of the categories are displayed on search results? Thanks in advance for any help or comments...

-jwm

Quote Reply
Re: Search Results Not Displaying All Categories In reply to
jwm,

Are you sure you want to do this?

As good as it might seem right now, if you remove the limiter you could end up with a massive search results page since the categories won't span pages like the search results do.

If you are expanding your directory then there is the likelyhood that a future search could match 150+ categories and they would all appear on the first page of the search results, leading to a massively long page when the first x no. of links are added to the bottom as well. I'm sure most people wouldn't care to spend the time looking through that many categories before finding the links and you could end up rendering your search results useless.

I'm sorry that I can't help with an actual solution, you'll have to ask some of the more experienced members of the forum as my knowledge is very limited Smile

All the best
Shaun

Quote Reply
Re: Search Results Not Displaying All Categories In reply to
Thanks, I understand what you mean, but still would like to set the upper limit above 25, so I'm hoping that someone might know how to raise the number of categories that are returned.

-jwm

Quote Reply
Re: Search Results Not Displaying All Categories In reply to
OK, I figured it out. search.cgi appears to use the variable 'mh' to set the limit for the number categories and links to return, by using it for the value of $maxhits in DBSQL.pm at sub query

What I've done is copied the 'mh' setting, and changed it for the category search results so its higher (500 hits), and changed it back again to the default setting for the links search results.

Make a backup of search.cgi then find ...
Code:
# Get/Set the search options.
($in->param('mh') =~ /^(10|25|50|100)$/) ? ($mh = $1) : ($mh = 25);
($in->param('bool') =~ /^(and|or)$/i) ? ($bool = uc $1) : ($bool = 'AND');
($in->param('nh') =~ /^(\d+)$/) ? ($nh = $1) : ($nh = 1);
Copy and remove the first line ...

($in->param('mh') =~ /^(10|25|50|100)$/) ? ($mh = $1) : ($mh = 25);

Now go a little further down and paste it here ...

Code:
# Now let's search the links table, but first figure out any filters.
($in->param('mh') =~ /^(10|25|50|100)$/) ? ($mh = $1) : ($mh = 25);
$linkdb = new Links::DBSQL "$LINKS{admin_root_path}/defs/Links.def";
After that, update # Search the category listings., to the following ...
Code:
# Search the category listings.
($in->param('mh') =~ /^(500)$/) ? ($mh = $1) : ($mh = 500);
$catdb = new Links::DBSQL "$LINKS{admin_root_path}/defs/Category.def";
$cat_hits = $catdb->query ( { query => $query, mh => $mh, nh => $nh } );
That should do it. Obviously you can change the '500' limit to whatever you feel comfortable with.

Let me know how you get on.

All the best
Shaun
Quote Reply
Re: Search Results Not Displaying All Categories In reply to
Wow, thanks very much for checking this out and finding a solution. I'll give this a try and let you know how it works for me. Thanks again.

-jwm

Quote Reply
Re: Search Results Not Displaying All Categories In reply to
Hi,

In Reply To:
($in->param('mh') =~ /^(500)$/) ? ($mh = $1) : ($mh = 500);
means you always set $mh ( the maxhits ) to 500 regardless which parameter ( $in->param('mh') ) was given. It would have been easier to set

$mh=500;

before doing the category search. Wink


regards, alexander

Quote Reply
Re: Search Results Not Displaying All Categories In reply to
Alex,

Thanks for the tip, I'm still learning perl - well trying my best anyway Smile

All the best
Shaun