Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mod for Search Results Template

Quote Reply
Mod for Search Results Template
I didn't like seeing the following kinds of results on my search results pages:

Your search returned 0 categories and 1 links

I wanted to see results like this:

Your search returned 1 category and 12 links
Your search returned 1 link
Your search returned 8 categories and 1 link
Your search returned 17 links

etc.

So, I used the following code in my search_results.html file. You must install Alex's Enhanced Template Support mod in the Template.pm file before using this code.



Your search returned

<%if cat_hits eq 1%>
<strong> <%cat_hits%> </strong>Category
<%endif%>

<%if cat_hits gt 1%>
<strong> <%cat_hits%> </strong>Categories
<%endif%>

<%if cat_hits gt 0%>
<%if link_results%>
and
<%endif%>
<%endif%>

<%if link_hits eq 1%>
<strong><%link_hits%> </strong>Link
<%endif%>

<%if link_hits gt 1%>
<strong><%link_hits%> </strong>Links
<%endif%>
Quote Reply
Re: Mod for Search Results Template In reply to
Very nice Mod! I would recommend posting it in the Resource Center!

Smile

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Mod for Search Results Template In reply to
like Yahoo, yeah, i got to that a while ago, but differently, yours probably works better, good job.
Quote Reply
Re: Mod for Search Results Template In reply to
I have finally put a link to this mod in the Resources section. Actually it's not a mod, but a good way to take advantage of the capabilities of Alex's Enhanced Template Support Mod.

If anyone else has found uses for the gt/lt functions which Alex's mod allows, I would be very interested to hear of them.

Best wishes to all,
Floristan

Quote Reply
Re: Mod for Search Results Template In reply to
I didn't use the gt/lt tags, but using "if term eq" and "ifnot term eq" I wrote an easter egg page that you'd get if you type a certain word (case-sensitive) in the search form. The results from the search are bypassed and a .txt file loads up with a couple of funny things.

--Drew
Quote Reply
Re: Mod for Search Results Template In reply to
Hi!
almost everything works great. in ourlanguage (slovenian) we don't have just Link (povezavo = 1) and Links (povezave = 3...and up)but we also have in our grammatic povezavi (2 links).

so my code is something like this

<%if link_hits eq 1%>
<strong><font face="verdana" size="3"><%link_hits%></font> </strong><font face="Verdana"><font size="2">povezavo
<%endif%>

<%if link_hits eq 2%>
<strong><font face="verdana" size="3"><%link_hits%> </strong><font face="Verdana"><font size="2">povezavi</font>
<%endif%>

<%if link_hits eq 3%>
<strong><font face="verdana" size="3"><%link_hits%> </strong><font face="Verdana"><font size="2">povezave
<%endif%>

<%if link_hits gt 4%>
<strong><font face="verdana" size="3"><%link_hits%> </strong><font face="Verdana"><font size="2">povezav
<%endif%>

but for hits (links) from 3 and up is nor displaying..something must be in code..but i cannot find it..

any help please.
thanx
gregor

Quote Reply
Re: Mod for Search Results Template In reply to
 
Here's a Perl version of the "Grammatically Correct"
search term mod which I've done for non-template/cgi
users.

Thanks to Floristan for his effort on producing
the original template version of this mod

-----------------------------------------------
Add the code below to your "site_html.pl" file
under the search results section.
-----------------------------------------------

Your search returned~;

{
if ($cat_hits eq 1) {
print qq~<strong> $cat_hits </strong>category~;
}
}


{
if ($cat_hits gt 1) {
print qq~<strong> $cat_hits </strong>categories~;
}
}

{
if ($cat_hits gt 0 and $link_results) {
print qq~ and~;
}
}

{
if ($link_hits eq 1) {
print qq~<strong> $link_hits </strong>site~;
}
}

{
if ($link_hits gt 1) {
print qq~<strong> $link_hits </strong>sites~;
}
}

.......................
IDNET UK LIMITED
www.idnetuk.com
......................
Quote Reply
Grammatically Correct Search Term Mod (Perl Ver) In reply to
 
Here's a Perl version of the "Grammatically Correct"
search term mod which I've done for non-template/cgi
users.

Thanks to Floristan for his effort on producing
the original template version of this mod

-----------------------------------------------
Add the code below to your "site_html.pl" file
under the search results section.
-----------------------------------------------

Your search returned~;

{
if ($cat_hits eq 1) {
print qq~<strong> $cat_hits </strong>category~;
}
}


{
if ($cat_hits gt 1) {
print qq~<strong> $cat_hits </strong>categories~;
}
}

{
if ($cat_hits gt 0 and $link_results) {
print qq~ and~;
}
}

{
if ($link_hits eq 1) {
print qq~<strong> $link_hits </strong>site~;
}
}

{
if ($link_hits gt 1) {
print qq~<strong> $link_hits </strong>sites~;
}
}

.......................
IDNET UK LIMITED
www.idnetuk.com
......................
Quote Reply
Re: Mod for Search Results Template In reply to
Gregor,

Starting with your statement for three hits you are missing the closing font tag. Actually, it is unnecessary to have font tags for every if statement.

Place an opening font tag before the entire section of code, and a closing font tag after.



Floristan


Quote Reply
Re: Mod for Search Results Template In reply to
WOW!!! What a ~COOL MOD~ !!!

This mod should be included in the original Links program files. I cannot believe how good this thing works. Install this mod and do a search for the word 'and.' This mod rocks --- a must have for Links 2.0 CGI users...

-------------------------
See Lenon.com Links 2.0
http://www.lenon.com