Gossamer Forum
Home : Products : DBMan : Customization :

Better formatting of HTML

Quote Reply
Better formatting of HTML
I'm trying to get better looking search results from my DBMan db. Ideally, I'd like the search results to resemble a business card when the approprate search criteria are met.

The problem: when a record does not have information included for a certain field, there is a blank line left in the search results. It looks something like this:

John Q. Public
123 Main St.

Los Angeles, CA 90245
213-555-1212

john@whatever.com

(where the blank lines would be a empty second address field and an empty fax field respectively).

I've experimented with having <BR> tags included in the database data itself, and that works to a degree, but that method breaks down when you do a search on a field and the URL encoding changes <BR> to gibberish and it can't make a match with anything in the database.

Any thoughts?
Quote Reply
Re: Better formatting of HTML In reply to
The best thing to do is add if statements that only show that line of code if there is a value in the field.

Try this:

Code:
HTML STUFF
|;
if ($rec{'FieldName'}) {
print qq|<$font>$rec{'FieldName'}|;
}
print qq|
HTML STUFF

Replace FieldName with your field names in default.cfg file.

Hope this helps.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Better formatting of HTML In reply to
Excellant! Thanks for your help, and so fast too!
Quote Reply
Re: Better formatting of HTML In reply to
Also, is there anyway to change the way found search criteria are displayed? Say, changing it from it's default of bold to red?

Thanks
Quote Reply
Re: Better formatting of HTML In reply to
Sure.

Find these codes in db.cgi file:

Code:
# Bold the results

if ($db_bold and $in{'vr'}) {
for $i (0 .. (($#hits+1) / ($#db_cols+1)) - 1) {
$offset = $i * ($#db_cols+1);
foreach $field (@search_fields) {
$hits[$field + $offset] =~ s,(<[^>]+> )|($regexp_bold[$field]),defined($1) ? $1 : "<B>$2</B>",ge;
}
}
}
return ("ok", @hits);
}

Change these codes to the following:

Code:
# Highlight the Search Results

if ($db_bold and $in{'vr'}) {
for $i (0 .. (($#hits+1) / ($#db_cols+1)) - 1) {
$offset = $i * ($#db_cols+1);
foreach $field (@search_fields) {
$hits[$field + $offset] =~ s,(<[^>]+> )|($regexp_bold[$field]),defined($1) ? $1 : "<B><font color="ff0000">$2</B></font>",ge;
}
}
}
return ("ok", @hits);
}

Hope this helps.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Better formatting of HTML In reply to
Great! Thanks for all your help.
Quote Reply
Re: Better formatting of HTML In reply to
Great! Glad it worked.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us