Gossamer Forum
Home : Products : DBMan : Discussions :

Adding mailto:

Quote Reply
Adding mailto:
In the unoffical FAQ it gives a snipet of code to add to make an email field clickable by adding mailto:

if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|Email Address: <a href="mailto:$rec{'Email'}">$rec{'Email'}</a> |;
}

Where should this snipet be placed???

Quote Reply
Re: Adding mailto: In reply to
Uh...in the sub html_record routine in the html.pl file as mentioned in quite a few Threads in the DBMAN Customization Forum.

Regards,

Eliot Lee
Quote Reply
Re: Adding mailto: In reply to
Yes I realize that, but where in the sub html_record? I have it in there but it doesn't seem to be working correctly.

Quote Reply
Re: Adding mailto: In reply to
Where you have all the other $rec{'FieldName'} codes.

And the problem with the codes that you provided is that you need to put operators around the codes, like the following:

Code:

|;
if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|Email Address: <a href="mailto:$rec{'Email'}">$rec{'Email'}</a> |;
}
print qq|


Regards,

Eliot Lee
Quote Reply
Re: Adding mailto: In reply to
I must be doing something wrong


my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';


print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#CCCC99">
|;
if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|Email Address: <a href="mailto:$rec{'Email'}">$rec{'Email'}</a> |;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Title:</FONT></TD>
<TD> <$font>$rec{'Title'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Type: </FONT></TD>
<TD> <$font>$rec{'Type'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Category:</FONT></TD>
<TD> <$font>$rec{'Category'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Description:</FONT></TD>
<TD> <$font>$rec{'Description'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Validated:</FONT></TD>
<TD> <$font>$rec{'Validated'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Popular:</FONT></TD>
<TD> <$font>$rec{'Popular'}</Font></TD></TR

Quote Reply
Re: Adding mailto: In reply to
In Reply To:
I must be doing something wrong
You sure are....

Okay...here is what you need to do...

Replace the codes you have with the following:

Code:

print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#CCCC99">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Title:</FONT></TD>
<TD> <$font>$rec{'Title'}</Font></TD></TR>

|;
if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email Address:</FONT></TD>
<TD> <$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a></FONT></TD></TR>|;
}
print qq|

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Type: </FONT></TD>
<TD> <$font>$rec{'Type'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Category:</FONT></TD>
<TD> <$font>$rec{'Category'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Description:</FONT></TD>
<TD> <$font>$rec{'Description'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Validated:</FONT></TD>
<TD> <$font>$rec{'Validated'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Popular:</FONT></TD>
<TD> <$font>$rec{'Popular'}</Font></TD></TR>


Really basic HTML...with a little bit of Perl. Wink


Regards,

Eliot Lee
Quote Reply
Re: Adding mailto: In reply to
It still does nothing

Here is what I have in sub html_record

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#CCCC99">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Title:</FONT></TD>
<TD> <$font>$rec{'Title'}</Font></TD></TR>
|;
if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email Address:</FONT></TD>
<TD><$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a></FONT></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Type: </FONT></TD>
<TD> <$font>$rec{'Type'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Category:</FONT></TD>
<TD> <$font>$rec{'Category'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Description:</FONT></TD>
<TD> <$font>$rec{'Description'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Validated:</FONT></TD>
<TD> <$font>$rec{'Validated'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Popular:</FONT></TD>
<TD> <$font>$rec{'Popular'}</Font></TD></TR>

</TABLE>


|;
}



****And here is my field definitions

# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
Name => [0, 'alpha', 40, 255, 1, '', ''],
Email => [1, 'alpha', 40, 60, 1, '', ''],
Branch => [2, 'alpha', 40, 40, 1, '', ''],
Units_Commanded => [3, 'alpha', '40x3', 200, 0, '', ''],
Locations => [4, 'alpha', '40x3', 200, 0, '', ''],
Competencies => [5, 'alpha', '40x6', 400, 0, '', ''],
);

Quote Reply
Re: Adding mailto: In reply to
Okay...what I would do is following....

1) Edit the Email field definition...(You should do the error/format checking upon records being added)....

Code:

Email => [1, 'alpha', 40, 60, 1, '', '.+\@.+\..+'],


2) Then replace the following codes in the sub html_record:

Code:

|;
if ($rec{'Email'} =~ /.+\@.+\..+/) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email Address:</FONT></TD>
<TD><$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a></FONT></TD></TR>
|;
}
print qq|


with the following codes:

Code:

|;
if ($rec{'Email'} ne "") {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email Address:</FONT></TD>
<TD><$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a></FONT></TD></TR>
|;
}
print qq|


These changes SHOULD REALLY fix the problem. Wink


Regards,

Eliot Lee
Quote Reply
Re: Adding mailto: In reply to
First I really want to thank you for all of your help. (but however,) Its still not working

%db_def = (
Name => [0, 'alpha', 40,60,1,'',''],
Email => [1, 'alpha', 40, 60, 1, '', '.+\@.+\..+'],
Branch => [2, 'alpha', 40, 40, 1, '', ''],
Units_Commanded => [3, 'alpha', '40x3', 200, 0, '', ''],
Locations => [4, 'alpha', '40x3', 200, 0, '', ''],
Competencies => [5, 'alpha', '40x6', 400, 0, '', ''],

And from html.pl

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#CCCC99">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Title:</FONT></TD>
<TD> <$font>$rec{'Title'}</Font></TD></TR>
|;
if ($rec{'Email'} ne "") {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email Address:</FONT></TD>
<TD><$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a></FONT></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>

You can see the testing site at
http://www.companycommand.com/testing.htm

I am sure this is still something really silly

THANKS!

Quote Reply
Re: Adding mailto: In reply to
Betcha that you have AUTO-GENERATION turned ON. The codes I've provided and you've inserted ONLY WORK WITH the AUTO GENERATION option turned OFF!!! Look in your default.cfg for the AUTO GENERATION variable AND TURN IT OFF! Tongue

Regards,

Eliot Lee
Quote Reply
Re: Adding mailto: In reply to
You da man. It works now but I lose all of the other field information. I suppose this has to do with turning the auto gen off. Perhaps I should read the tutorial on customizing output so that I can get all the desired field information.

Who should I write the check out to?

THANKS!

Quote Reply
Re: Adding mailto: In reply to
You need to have ALL the fields referenced ($rec{'FieldName'}) in the sub html_record routine. Without using auto-generation, you need to format the result pages yourself via the sub html_record routine.

Regards,

Eliot Lee