Gossamer Forum
Home : Products : Links 2.0 : Customization :

Editing Search Results - The category value.

Quote Reply
Editing Search Results - The category value.
Hi,

Is it possible to change the category position in the search results generated by search.cgi?

Example Search Result:

Business and Economy

Yahoo
www.yahoo.com
A search directory
Rate It


But i would like it so it says something like this :

Yahoo
www.yahoo.com
A search directory
Category : Business and Economy
Rate It

How would I be able to do this?

Many Thanks,

Kingy.
Quote Reply
Re: Editing Search Results - The category value. In reply to
If you want to take out the category listing before the links...and put the category within the link results, you will have to do the following:

1) Delete the following line in the search.cgi script:

Code:
$link_results .= qq|$title_linked|;

2) Then you will have to create a sub-routine called sub site_html_search_link routine, which should be a copy of your sub site_html_link routine, yet you will load search_link.html rather than link.html file.

3) Then create a new template file called search_link.html file. This should be a copy of your link.html, except it should look like the following:

Code:
<%Title%><br>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">
<%URL%></a><br>
<%if Description%>
<%Description%><br>
<%endif%>
<b>Category:</b> <a href="<%build_root_url%>/<%Category%>"><%Category%></a><br>
<a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It!</a>

Now...keep in mind that the Category Name will not appear in "clean" format. The codes would have to be tweaked a bit to include the Category name in "clean" format.

4) Back to the search.cgi script, change all occurences of &site_html_link to &site_html_search_link.

That should do it.

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Editing Search Results - The category value. In reply to
Thanks Elliot,

If someone could post the 'tweaked' version so it has a 'clean' output, then that would be much appriciated!

Also, how could i use the 'clean' routine to have the categories in the drop-down box in the add.cgi without the underscores?

Many Thanks,

Kingy.
Quote Reply
Re: Editing Search Results - The category value. In reply to
You need to use the following for the category drop-down menu in the add form:

Code:
my $category = shift;
my $clean_category = &build_clean($category);
$category ?
($category = qq~$clean_category <input type=hidden name="Category" value
="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));

in the sub site_html_add_form and also in the sub site_html_add_failure.

Then define the Category tag as follows in both of these subs:

Code:
Category => $category,

For the clean category in the search results, add the following at the top of the sub site_html_search_link:

Code:
$printcat = &build_clean($rec{'Category'});

Then define this tag as follows:

Code:
printcat => $princat,

Remove the comma if this is the last field in the tag definitions area of this sub.

Then in your search_link.html template file, replace the following codes:

Code:
<b>Category:</b> <a href="<%build_root_url%>/<%Category%>">
<%Category%></a><br>
<a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It!</a>

with the following codes:

Code:
<b>Category:</b> <a href="<%build_root_url%>/<%Category%>">
<%printcat%></a><br>
<a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It!</a>

I don't gaurantee these codes will work, but you can try it.

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 15, 2000).]
Quote Reply
Re: Editing Search Results - The category value. In reply to
Eliot,

I tried the code you gave me but I get the following error msg :

Error including libraries: Can't modify constant item in scalar assignment at /home/speedcity/www/cgi-bin/admin/site_html_templates.pl line 85, near "$princat
}"

Make sure they exist, permissions are set properly, and paths are set correctly.


Do you know what is causing this?

Many Thanks,

Kingy.
Quote Reply
Re: Editing Search Results - The category value. In reply to
Seems like you have overlooked the following instructions in my Reply:

Quote:
Remove the comma if this is the last field in the tag definitions area of this sub.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Editing Search Results - The category value. In reply to
But it is not the last one, my coding looks like this :

$printcat = &build_clean($rec{'Category'});

my %rec = @_;

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('search_link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
printcat = $princat,
%rec,
%globals
});
}

Is this right? Have i put something in the wrong place?
Quote Reply
Re: Editing Search Results - The category value. In reply to
UGH...*sigh*...

No, it is a syntax error on my part....

Change the following:

Code:
printcat = $princat,

to the following:

Code:
printcat => $princat,

I apologize for the syntax error...Although I wish that more people would learn to think out of the box (codes) and see relationships, and be able to fix errors on their own...Oh well.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Editing Search Results - The category value. In reply to
Thanks, it now works...........well sort of anyway.

The original coding you gave me for the search_link.html :

<b>Category:</b> <a href="<%build_root_url%>/<%Category%>"><%Category%></a><br>

works, but the most recent coding which you said :

<b>Category:</b> <a href="<%build_root_url%>/<%Category%>">
<%printcat%></a><br>

does not. It just displays :

Category :

and no category is shown.

Any more words of wisdom on this?

I ideally wanted it not to be linked, but i also wanted it to be 'clean'.

e.g. Business and Economy

rather than Business_and_Economy

Many Thanks,

Kingy.

Quote Reply
Re: Editing Search Results - The category value. In reply to
I know what you want...thanks for reminding me...(not) Frown. I am trying to help you. So, the codes that I gave you didn't work, well let's try another solution, okay.

"Beggers cannot be choosers"

Try replacing the following codes:

Code:
$printcat = &build_clean($rec{'Category'});

with the following codes:

Code:
my $printcat = shift;
$printcat = &build_clean($rec{'Category'});

Again, I do not gaurantee if these codes will work...basically trial by error.

Wink

Regards,



------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Editing Search Results - The category value. In reply to
I tried editing the codes with what you said Eliot, but then i got all the links saying unknown ID :

e.g.

should look like :

Yahoo
www.yahoo.com
A search directory
Category : Business and Economy
Rate It

But the coding changed everything to :

Unknown ID
Unknown ID
Unknown ID
Category : Unknown ID
Rate It

I appricate your help on this Eliot. Anymore ideas?

Many Thanks,

Kingy.


Quote Reply
Re: Editing Search Results - The category value. In reply to
The Unknown ID tag has nothing to do with the codes I posted. The codes I posted only affect the Category field. What other changes have you made other than the ones I suggested?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Editing Search Results - The category value. In reply to
I haven't edited anything else just what you told me to edit.

But I keep getting the Unknown Tag error.


Any more ideas?

Cheers

Kingy
Quote Reply
Re: Editing Search Results - The category value. In reply to
I changed the coding back again so the category isn't a hyperlink, but it still isn't 'clean'.

Any more ideas to how this can be made clean?

Thanks,

Kingy.
Quote Reply
Re: Editing Search Results - The category value. In reply to
Nope...Sorry.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums