Gossamer Forum
Home : Products : DBMan : Customization :

Kinder & Gentler Elliot - records.cgi

(Page 1 of 2)
> >
Quote Reply
Kinder & Gentler Elliot - records.cgi
I have another example of your fine little mod running at http://www.fishhoo.com/.../stories/stories.htm and since I have noticed that you seem to be in a good mood, even after a poster called you Lee Elliot, I thought it might be a good time to ask about your progress in wrapping the results into table columns.



------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
hi...i just saw your site that works pretty good.
I would like to know which "fine littlte mod" do u use for your site??
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
I was speaking of records.cgi which is available in the Resource Center.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
I have tested some code hacks...and no success yet.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
If you want to use a table'd output of records.cgi you can try the below. It's not pretty but works fine for me. (replace the code just before the get_date sub)

..............................

$i = 1;

print qq|<table border="0" cellpadding="1" cellspacing="7">|;

foreach $field (sort @selectfields) {
$sfield = &urlencode($field);

if ($i%2) {
print qq|<tr><td bgcolor="#eeeeee">|;
}
else {
print qq|<td bgcolor="#eeeeee">|;
}

print qq|

<font face="arial, helvetica" size="3" color="#000000"><B><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend" onMouseOver="status=('$field'); return true"> $field</a></B> ($count{$field})</font><BR>

|;

if ($i%2) {
print qq|</td>|;
}
else {
print qq|</td></tr>|;

}

++$i;

}


print qq|</table>|;
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Good! Thanks! That workes for 2 columns. What would you change to make 4 columns?

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Will, you should be able to achieve your four column layout by experimenting with the $i%2, which effectively means if the variable $i is divisible by 2...
(hint: maybe a couple elsif statments and $i%3, $i%4, etc..)

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Thanks oldmoney, but I haven't had any luck with it. I even dug out my "Perl Cookbook" but couldn't find anything related. I swear if a local college offered a course in Perl I would take it.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
This thread should get you a little closer... if you still can't get it, I'll whip it up later.
http://www.gossamer-threads.com/...m12/HTML/000880.html

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
My dear oldmoney,

I would truly appreciate your help with this. Not being a Perl programmer, (or maybe I'm just getting too damn old) I am having trouble getting my mind around the logic.

I think you will agree that 4 columns would be best at http://www.fishhoo.com/.../reports/reports.htm . You can see my 2 column records.cgi at http://www.fishhoo.com/recordscgi_2col.txt .

Thanks a bunch.




------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Since you tried... here ya go
Code:
$i = 0;
print "<table BORDER=2>\n";
for (0 .. ($numhits - 1)) {
# LOGIC: If divide last $i by 4 and no remainder, create new row - e.g. $i = 0, 4 (actually the FIFTH record since starting with 0), 8, etc...
if ($i%4 == 0) { print "<tr>"; }
# LOGIC: Put each record in its own cell
print "<td>";
&html_record (&array_to_hash($_, @hits));
print "</td>";
++$i;
# LOGIC: If divide last $i by 4 and no remainder, end row - e.g. $i = 4 (we just incremented $i so can never be 0), 8, etc...
if ($i%4 == 0) { print "</tr>\n"; }
}
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 1 => create 3 (4-1) blank cells
if ($i%4 ==1) { print "<td COLSPAN=3></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 2 => create 2 (4-2) blank cells
elsif ($i%4 ==2) { print "<td COLSPAN=2></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 3 => create 1 (4-3) blank cell
elsif ($i%4 ==3) { print "<td></td></tr>\n"; }
print "</table>";


With this code and comments, hopefully anybody can adapt it to tables of N columns...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Thanks for the codes, oldmoney...The one thing I was missing in my attempts is the elsif statements you've included.

Smile

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
So, where in all that do we actually put
Code:
<font face="arial, helvetica" size="2" color="#000000"><B>
<a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend"
onMouseOver="status=('$field'); return true"> $field</a></B> <$smfont>
(<font color="ff0000">$count{$field}</font> )</font><BR>
?
Boy, you guys have me feeling stupid.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com


[This message has been edited by willdeb (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Bad post...

[This message has been edited by oldmoney (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Sh*t!

No wonder I have been having such problems. I asked for help with records.cgi, not default_html.pl.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Sorry if I led you astray... I guess I forgot that you were working
with records.cgi (which I have never looked at), but I don't see why the
multi-column codes wouldn't work in records.cgi as well.

Try substituting your formatting code in a print qq statement for
&html_record (&array_to_hash($_, @hits));

Should work in theory...


------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Actually to make the codes work that oldmoney provided...All you have to do is add another require line in the record.cgi file:

Code:
require "/path/to/cgi-bin/dbman/html.pl";

Then in the html.pl file, format the sub html_record to how you want the articles to appear.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
This
Code:
$i = 0;
print "<table BORDER=2>\n";
for (0 .. ($numhits - 1)) {
# LOGIC: If divide last $i by 4 and no remainder, create new row - e.g. $i = 0, 4 (actually the FIFTH record since starting with 0), 8, etc...
if ($i%4 == 0) { print "<tr>"; }
# LOGIC: Put each record in its own cell
print "<td>";
print "<font face=arial,helvetica size=2 color=000000><B><a href=$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend onMouseOver=status=('$field'); return true> $field</a></B> <$smfont>(<font color=ff0000>$count{$field}</font> )</font><BR>";
print "</td>";
++$i;
# LOGIC: If divide last $i by 4 and no remainder, end row - e.g. $i = 4 (we just incremented $i so can never be 0), 8, etc...
if ($i%4 == 0) { print "</tr>\n"; }
}
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 1 => create 3 (4-1) blank cells
if ($i%4 ==1) { print "<td COLSPAN=3></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 2 => create 2 (4-2) blank cells
elsif ($i%4 ==2) { print "<td COLSPAN=2></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 3 => create 1 (4-3) blank cell
elsif ($i%4 ==3) { print "<td></td></tr>\n"; }
print "</table>";
returns
Code:
<table BORDER=2>
</table>

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
OK, I just looked at records.cgi.
$numhits is not being defined... try replacing it with @selectfields...

In fact, the whole multi-column mod needs to go in this loop, replacing the existing print qq statement...
Code:
foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
print qq|<$font><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend">$field</a>:</font> <$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;
}

<EDITED>
If Eliot says its $count, its $count... Wink

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
$count is the equivalent code.

BTW: The generic codes for records.cgi is located at:

www.anthrotech.com/cgi/dbman/mods/records.txt

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 26, 2000).]
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
oldmoney,

I feel bad about complaining because I know you're trying to help, but you're only frustrating the hell out of me. I'm not a perl programmer but I am trying to implement the codes that you are only hinting at. If you can, try to be specific.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
What oldmoney is getting at is that you have to replace the following line:

Code:
print qq|<$font><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend">$field</a>:</font> <$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;

With the multi-column codes that oldmoney provided...

Code:
foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
$i = 0;
print "<table BORDER=2>\n";
for (0 .. ($numhits - 1)) {
# LOGIC: If divide last $i by 4 and no remainder, create new row - e.g. $i = 0, 4 (actually the FIFTH record since starting with 0), 8, etc...
if ($i%4 == 0) { print "<tr>"; }
# LOGIC: Put each record in its own cell
print "<td>";
&html_record (&array_to_hash($_, @hits));
print "</td>";
++$i;
# LOGIC: If divide last $i by 4 and no remainder, end row - e.g. $i = 4 (we just incremented $i so can never be 0), 8, etc...
if ($i%4 == 0) { print "</tr>\n"; }
}
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 1 => create 3 (4-1) blank cells
if ($i%4 ==1) { print "<td COLSPAN=3></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 2 => create 2 (4-2) blank cells
elsif ($i%4 ==2) { print "<td COLSPAN=2></td></tr>\n"; }
# LOGIC: Do we need to handle "odd" number of records? If divide last $i and remainder of 3 => create 1 (4-3) blank cell
elsif ($i%4 ==3) { print "<td></td></tr>\n"; }
print "</table>";
}

Right, oldmoney?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Elliot, I still don't see where that prints the field I want displayed. I got the feeling you think I'm using the short-long mod. I'm not. That's why records.cgi is important to me.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
Okay...first of all, replace the following codes:

Code:
for (0 .. ($numhits - 1)) {

with the following:

Code:
for (0 .. ($count - 1)) {

Then in the sub html_record routine in the html.pl file, print the fields that you want to be printed, like the following:

Code:
$rec{'FieldName'}

With the codes that oldmoney provided, you are no longer using the print statement for $sfield. You are formatting the HTML in the html.pl file.

And you need to require the html.pl file like the following (as I suggested earlier):

Code:
require "/path/to/cgi-bin/dbman/html.pl";

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Kinder & Gentler Elliot - records.cgi In reply to
You need to edit the sub html_record in the following manner:

Code:
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);

$rec{$db_key} =~ s/<.?B>//g;
print qq|
<a href="$db_script_link_url&ww=on&$db_key=$rec{$db_key}&view_records=1">$rec{'State'}</a>
|;
}

Then you will have to create a new sub-routine called sub html_record_long. This routine should look like the following:

Code:
sub html_record_long {
#-----------------------------------------
# Long Record

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

foreach $column (@db_cols) {
$rec{$column} =~ s/~~/, /g;
}
$rec{'Report'} =~ s/\n/<BR>/g;
$rec{'Techniques_And_Tips'} =~ s/\n/<BR>/g;
print qq|
Report: $rec{'Report'}
Techniques and Tips: $rec{'Techniques_And_Tips'}
|;
}

Another suggestion rather than linking to the sub html_record_long is that you use Widgetz's detail.cgi script for printing the detailed view.

His script is located at:


Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 27, 2000).]
> >