Gossamer Forum
Home : Products : Links 2.0 : Customization :

In search results don't group results by category - but print featured listings first and then the rest?

Quote Reply
In search results don't group results by category - but print featured listings first and then the rest?
Hi,

Is it possible to show search results instead of grouping them by alphabetical categories, ungroup them and show all featured links first and then the rest.

For example: if I have categories names Automotive, Business, etc., normally when I search in the results page, all results from the Automotive category are grouped and listed first and then the results from Business are grouped and printed and so on..

I created a field in links.def called "featured" yes/no which will show the featured listings first in category pages and then the rest. I want to do the same for search result listings so when someone does a search instead of seeing results grouped by category they will see all featured listings first and then the rest.

Thanks

Last edited by:

socrates: Mar 11, 2006, 1:06 AM
Quote Reply
Re: [socrates] In search results don't group results by category - but print featured listings first and then the rest? In reply to
This will remove the category names, but the results will sort by category. In sub main:

Code:
# Go through the hash just built, and build the complete link output. Store in $link_results.
foreach $setoflinks (sort keys %link_output) {
$cat_clean = &build_clean ($setoflinks);
$title_linked = &build_linked_title ($setoflinks);
# blocking next line removes category results >
#
$link_results .= qq|<P>$title_linked\n|;
$link_results .= $link_output{$setoflinks};
}




This will sort with no reference to categories.

In sub search change:
Code:
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}

to
Code:
#If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values}}, @values);
$numhits++; # We have a match!
}


To sort by a selected field will require a bit more work. You may get the Relevancy Mod to do what you want. Read this thread: http://www.gossamer-threads.com/...i?post=277630#277630


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] In search results don't group results by category - but print featured listings first and then the rest? In reply to
Have you achieved the results you want? The sorting changes in the Priority Logo Mod will do what you want, the code is attached.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] In search results don't group results by category - but print featured listings first and then the rest? In reply to
Yes, thanks very much for the suggestion. I installed priority mod long-time ago. Once it is installed, with your answer in post #2 is all you need to do in sub search and then it will automatically sort out priority links first and then new and then the rest.

Just that one-line and I did not have to do anything else.

Thanks