Gossamer Forum
Home : Products : DBMan : Installation :

Configurator+short/long display mod

Quote Reply
Configurator+short/long display mod
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
Quote Reply
Re: Configurator+short/long display mod In reply to
Where you have the codes placed in your examples above are the correct location.

You may also want to add the following:

$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;

in your sub html_record_long {

after: my (%rec) = @_;

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Configurator+short/long display mod In reply to
Hi Lois,

thanks, but the two subs have to be combined.

The sub_html_record has to be added to or has to replace the code in sub html_record_long.

Maybe you can show me where and how to do this?



Thanks a lot!
Byebye
Gil
Quote Reply
Re: Configurator+short/long display mod In reply to
Okay, I should have looked closer.
What you have in your html_record is what displays the field contents.

The configurator should have provided you with the codes with the form input fields which should be placed in that sub.

The html_record_long is for the codes which display the contents of the fields. From what you have above it looks like you placed the same coding in both subs.

I hope this is clear, if not, read the files again that were given to your after running the configurator .. it should state which codes get placed in which sub.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Configurator+short/long display mod In reply to
Hi Lois,

The point is that the configurator code for sub html_record appears to be in sub html_record_long if you installed the short/long display mod. I know where to place the code in sub html_record_long only I don't know if I have to use this line:

my (%rec) = @_;

once or twice

In the beginning of the sub, further on where the record display starts, or both?

It doesn't make a difference if I use my (%rec) = @_;
once or twice but I am not sure why it doesn't make a difference.

Wish I could make it a little clearer :(

Thanks a lot
Gil

Below is the sub html_record_long the way I use it now.

sub html_record_long {
#----------------------------------------------------------------
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 -->
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||;
etc
etc
etc
etc

Thanks a lot!
Byebye
Gil
Quote Reply
Re: Configurator+short/long display mod In reply to
You only need that line once at the beginning of the sub:

sub html_record_long {
#-------------------------------------------------
my (%rec) = @_;

You can delete the second entry of my (%rec) = @_; you inserted further down in that sub.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Configurator+short/long display mod In reply to
Thanks Lois,

That's what I needed to know. Sometimes I'm getting a little nervous when modifying scripts while I'm not sure if the code is still the way it should be.



Thanks a lot!
Byebye
Gil