Hi everybody,
I've been in doubt about something for a while. Maybe somebody can explain it to me. I use the userfriendly_html.pl + short/long display mod.
My databse has 42 fields so I use JPDeni's configurator to make life a little easier. The sub html_record generated by the configurator must be placed in sub html_record_long but I am not sure where exactly because of the following line:
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
I can place them right after the start of the sub_html_record and replace this line: my (%rec) = @_;
or I can add everything a little further on after this line:
<-- Start of record display -->
Both ways seem to work but I'd like to understand why and what is the best way to do it? I hope this post isn't to long.
Thanks for the help!
Gil
This is the sub_html_record from the configurator
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';
$rec{'Tuin2'} =~ s/\n/<BR>/g;
$rec{'Balkon2'} =~ s/\n/<BR>/g;
$rec{'Kelder2'} =~ s/\n/<BR>/g;
$rec{'Omschrijving'} =~ s/\n/<BR>/g;
$rec{'BG2'} =~ s/\n/<BR>/g;
$rec{'1e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'2e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'3e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'4e verdiepingb'} =~ s/\n/<BR>/g;
$url{'URL'} = $rec{'URL'};
$url{'URL'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>|;
if ($rec{'Adres'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Adres:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Adres'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Postcode'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Postcode:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Postcode'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Plaats'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Plaats:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Plaats'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Omgeving'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Omgeving:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Omgeving'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Type'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Type:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Type'}</Font></TD></TR>
|;
}
print qq|
</TABLE>
|;
}
and this is the sub html_record_long where I have to add the above sub:
sub html_record_long {
#----------------------------------------------------------------
# add and replace configurator code here?
my (%rec) = @_;
if ($db_total_hits > 1) {
# create links to previous and next records
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }
if ($next_hit <= $db_total_hits) {
$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }
# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;
# print out the links
print qq|
<table width=100%>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;
}
# Below is where you define your form.
# <-- Start of record display -->
# or add configurator code here?
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<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>
</TABLE>
|;
}
Thanks a lot!
Byebye
Gil
I've been in doubt about something for a while. Maybe somebody can explain it to me. I use the userfriendly_html.pl + short/long display mod.
My databse has 42 fields so I use JPDeni's configurator to make life a little easier. The sub html_record generated by the configurator must be placed in sub html_record_long but I am not sure where exactly because of the following line:
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
I can place them right after the start of the sub_html_record and replace this line: my (%rec) = @_;
or I can add everything a little further on after this line:
<-- Start of record display -->
Both ways seem to work but I'd like to understand why and what is the best way to do it? I hope this post isn't to long.
Thanks for the help!
Gil
This is the sub_html_record from the configurator
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';
$rec{'Tuin2'} =~ s/\n/<BR>/g;
$rec{'Balkon2'} =~ s/\n/<BR>/g;
$rec{'Kelder2'} =~ s/\n/<BR>/g;
$rec{'Omschrijving'} =~ s/\n/<BR>/g;
$rec{'BG2'} =~ s/\n/<BR>/g;
$rec{'1e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'2e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'3e verdiepingb'} =~ s/\n/<BR>/g;
$rec{'4e verdiepingb'} =~ s/\n/<BR>/g;
$url{'URL'} = $rec{'URL'};
$url{'URL'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>|;
if ($rec{'Adres'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Adres:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Adres'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Postcode'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Postcode:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Postcode'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Plaats'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Plaats:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Plaats'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Omgeving'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Omgeving:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Omgeving'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Type'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Type:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Type'}</Font></TD></TR>
|;
}
print qq|
</TABLE>
|;
}
and this is the sub html_record_long where I have to add the above sub:
sub html_record_long {
#----------------------------------------------------------------
# add and replace configurator code here?
my (%rec) = @_;
if ($db_total_hits > 1) {
# create links to previous and next records
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }
if ($next_hit <= $db_total_hits) {
$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }
# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;
# print out the links
print qq|
<table width=100%>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;
}
# Below is where you define your form.
# <-- Start of record display -->
# or add configurator code here?
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<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>
</TABLE>
|;
}
Thanks a lot!
Byebye
Gil