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

Formatting Search Results

Quote Reply
Formatting Search Results
Does anyone know how it would be possible to change the search results for the links part so that the links each have a line with the category where they came from (something similar to DMOZ)?

So rather than:

Category Name
Link 1
Link 2
Link 3, etc.

Next Category Name
Link 1
Link 2
Link 3

It would be:

Link 1
--Its Category

Link 2
--Its Category

Link 3
--Its Category

Thanks for help anyone could provide...

--Frank





Quote Reply
Re: Formatting Search Results In reply to
1) In order to have the category diplayed under the link in your search results and NOT in your category pages, you will need to use a different template file.....

a) Copy your sub site_html_link in the HTML_Templates.pm file and call the new subroutine: sub site_html_search_link.

b) Then in this new subroutine, load searchlink.html NOT link.html.

c) Create a new template file called searchlink.html and upload it in your templates directory.

2) Then in your search.cgi, replace all occurrences of &site_html_link with &site_html_search_link.

3) Rem out (#) or delete the following line of code in the search.cgi file:

Code:

$link_results .= "
" . &search_build_linked_title ($name) . "
\n";


in the sub search routine.

4) Then in your sub site_html_search_link routine in the HTML_Templates.pm file, add the following codes:

Code:

# Print Category and link to Category

my $catname = &Links::DB_Utils::get_category_name($rec->{CategoryID});
my $category = &Links::DB_Utils::build_clean_name($catname);


Then define the following tags in this subroutine:

Code:

printcat => $catname,
Category => $category


5) Then in your searchlink.html file, add the following codes:

Code:

<a href="/<%Category%>/"><%printcat%></a>


Regards,

Eliot Lee

Quote Reply
Re: Formatting Search Results In reply to
Eliot,

Thanks very much for your detailed reply. I will go ahead and try this.

--Frank

Quote Reply
Re: Formatting Search Results In reply to
You're welcome...and it should work...because I am using this hack in my site:

http://vlib.anthrotech.com/bin/search.cgi

Regards,

Eliot Lee

Quote Reply
Re: Formatting Search Results In reply to
Hello Eliot,

Thanks for the code and instruction. It's something I have been looking for. But when I tried it, it didn't work. I wonder if it still works no that I have upgraded to 1.13.

Thanks

Jian Liu
Indiana University Libraries
Quote Reply
Re: Formatting Search Results In reply to
It should work...unless the record hash codes have been dramatically changed in Version 1.13. Make sure you are hacking the correct subroutine in the HTML_Templates.pm file.

Regards,

Eliot Lee