Gossamer Forum
Home : Products : DBMan : Customization :

going from 2 column display to 4?

Quote Reply
going from 2 column display to 4?
right now i have the 2 column display and it works fine, but now i want 4 columns.. ive tried one mod but then i click on the long display it always takes me to the first record. this is my code:

sub html_view_success {
# --------------------------------------------------------
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);
$in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1);
$page_title = "Search Results";
&html_page_top;

# Go through each hit and convert the array to hash and send to

# html_record for printing.

if ($maxhits == 1) {
&html_record_long(&array_to_hash(0, @hits));
}
else {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
$rec_count = 1;
print "<table>";
print "<table>";
for (0 .. $numhits - 1) {
$i = $_;
unless ($i % 2) {
print "<tr>";
}
print "<td>";
&html_record (&array_to_hash($_, @hits));
print "</td>";
if ($i % 2) {
print "</tr>";
}
++$rec_count;
}
if ($numhits % 2) {
print "<td>&nbsp;</td></tr>";
}
print "</table>";
print "</tr>";
++$rec_count;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
print qq|</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}

what can i change to that to make it display 4 columns?

thanks in advance,
jake
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
anyone? Smile
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
Try replacing all instances of "$i % 2" by "$i % 4".
kellner
Quote Reply
Re: [kellner] going from 2 column display to 4? In reply to
thatd didnt work, it made mess up...
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
erm, could you explain more precisely what happened? "mess" is not a useful starting point for solving a problem. What sort of mess? error message? Messy table display? If so, how is the table display messy?

Also, you have two start table tags in your code, right after one another. Why do you need those?
kellner
Quote Reply
Re: [kellner] going from 2 column display to 4? In reply to
when i changed the twos to fours it looked kinda liek this:

E E
E
E
E
E

(E is the record) heh



i took the extra <table> out, it didnt make any difference.
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
i tired this mod:

# In sub html_view_success, there are two lines that say

if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }

# Between those lines is where your records print out.

# Replace whatever is between those lines with the following:

#--------------------------------------------------------------------
$i = 1;
$cols = 4; # Change this to the number of columns you want
print "<table>";
for (0 .. $numhits - 1) {
unless ($_%$cols) {
print "<tr>";
}
&html_record (&array_to_hash($_, @hits));
if ($_%$cols==($cols-1)) {
print "</tr>\n";
}
++$i;
}
if ($numhits%$cols) {
for ($j=($cols-1);$j>=$numhits%$cols ;$j--) {
print "<td>&nbsp;</td>";
}
print "</tr>\n";
}
print "</table>";



but when i click on the long display it takes me to the first record no matter which one i click on...

so.. how can i combine the two so i can have 4 columns and the links working? hehe



jake.
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
I guess the code for the link to the long record display is inside html_record, so one would need to know what your html_record looks like to find out what's wrong.
kellner
Quote Reply
Re: [kellner] going from 2 column display to 4? In reply to
heres my 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.

# This is the "short display" -- the list of records that are returned

# from a search.

my (%rec) = @_;

$rec{$db_key} =~ s/<.?B>//g;

### Wherever you want your graphics to print out, use the following:

# create link to full display

$record_number = ((($nh - 1) * $db_max_hits) + $rec_count);



$long_url = $ENV{'QUERY_STRING'};

$long_url =~ s/\&nh=\d+//;

$long_url =~ s/\&mh=\d+//;

$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";

print "<TD>"; # do not remove this! It is necessary to make the records display properly



# Below is where you define what you want to appear for each record in the "short" display.

# You can make this whatever you want, and display as many fields as you would like.

# Choose which of the fields you would like for users to click on to reach the full display

# of records and use that field name in place of "Title" below.

#

# Be sure that you use <a href="$long_url"> for the link to your full record display.

# <-- Start of short display formatting -- >

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=1

Color=#003399';

my $font = 'Font face="Verdana, Arial, Helvetica" Size=1';



print qq|

<table border="0" width="150" height="189" cellspacing="0" cellpadding="0">

<tr>

<td width="100%" height="92">|;

if (-e "$SAVE_DIRECTORY/$rec{$db_key}") {

opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");

@files = readdir(GRAPHIC);

closedir (GRAPHIC);

foreach $file (@files) {

next if ($file =~ /^\./); # Skip "." and ".." entries..

next if ($file =~ /^index/); # Skip index.htm type files..

print qq|<img src= "$SAVE_DIRECTORY_URL/$rec{$db_key}/$file" width="140" height="90" border="1">|;

}

}

print qq|</td>

</tr>

<tr>

<td width="100%" height="37" valign="top"><font SIZE="1"><p align="center"><font

face="Arial"><strong>$rec{'address'}<br>

$rec{'location'}</strong></font></font></td>

</tr>

<tr>

<td width="100%" height="76" valign="top"><font face="Arial" SIZE="1"><strong></strong>Price:

$rec{'price'}</font><br>

<font size="1" face="Arial">Square Ft.: $rec{'totalfinished'}<strong><br>

</strong>ID: $rec{'ID'}<br>

<strong><br><a href="$long_url">

DETAILS</a></strong></font></td>

</tr></td>

</table>

|;



# if you want to display your fields in columns, use the following format:

# print qq|

# Add or remove columns as needed. Be sure you add the $long_url link to one of your fields

# <-- End of short display formatting -- >

}

Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
In html_view_success, you have two instances of "$i". First, a line "$i = 1", and a few lines further below, "$i++". Try replacing "$i" with "$rec_count".
kellner
Quote Reply
Re: [jakeot] going from 2 column display to 4? In reply to
Quote:
<a href="$long_url">DETAILS</a>

This is not linking to anything? You should have a field value in the link such as:

<a href="$long_url">$rec{'fieldname'}</a>

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] going from 2 column display to 4? In reply to
Why should there have to be a fieldname?
kellner
Quote Reply
Re: [kellner] going from 2 column display to 4? In reply to
It worked kellner! Smile Thanks for all your help, I really appreciate it!



Jake