Gossamer Forum
Home : Products : DBMan : Customization :

Top Ten

Quote Reply
Top Ten
I've got the counter working fine, but when I try to further use the Top Ten mod, it displays the html right, syntax is sound, but it doesn't pull any info/results in.

Further, I'm boggled by the "FieldName" comment in the mod -- I shouldn't have to create a field/fieldname, should I?

Yes, I've searched, yes I chmod 777, yes, I cut|copy|paste correctly from http://www.jpdeni.com/dbman/Mods/TopTen.txt (least I think I did). Unfortunately, my temp dir appears empty and there's no output on my top ten page.

I can post whatever *.txt files you might need or maybe you can tell me what bonehead thing I might be missing.

Thx in advance.

JR


------------------
Joebagodonuts, JR or Anita
http://home.flash.net/~murgnam/
Quote Reply
Re: Top Ten In reply to
OK, I piecemealed together from http://www.gossamer-threads.com/...m12/HTML/002612.html and got the column display working, but the count still doesn't seem to be right, :-0. Here's my sub html_topten
Code:
sub html_topten {
# --------------------------------------------------------
# Browse Top 10 hit records
$temp_dir = "/home/m/u/murgnam/www/cgi-bin/dbman/temp"; # Note there is no trailing slash!
opendir (TEMPDIR, "$temp_dir") or &cgierr("unable to open directory $temp_dir. Reason: $!");
@files = readdir(TEMPDIR); # Read in list of files in directory..
closedir (TEMPDIR);
FILE: foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
open (COUNTER, "<$temp_dir/$file") or &cgierr("unable to open file $temp_dir/$file. Reason: $!");
$count{$file} = int(<COUNTER> );
close COUNTER;
}
foreach $key (sort {$count{$b} <=> $count{$a} } keys %count) {
push (@top_ten,$key);
}

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Top 10 Records</title>
</head>
<body background="http://home.flash.net/~murgnam/S2.JPG">
|;
print qq|

<center>
<table border=1 background="http://home.flash.net/~murgnam/texture3.jpg" cellpadding=5 cellspacing=3 width=550 align=center valign=top>
<tr><td>
<$font_title>
<b><A HREF="$db_script_link_url">$html_title</a> :<br>Top 10 Records</b>
</font>
<p>
<$font>
Top 10 Records. Listing of the Top 10 records hit in the database.
<p>|;

for ($i=0;$i<10 ;$i++) {
$toparray .= "$top_ten[$i],";
}
chop $toparray;
foreach my $toplist (split(/,/,$toparray)) {
%rec=&get_record($toplist);
print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&mh=1&view_records=1">$rec{'UserID'}</a><BR>|;
}
&html_footer;
print qq|
</td></tr>
</table>
|;
print qq|
</center>
</body></html>
|;
}
Is there anything in there, that explains why my count isn't working plus my ref to using a field other that UserID (db_key)?
JR
Quote Reply
Re: Top Ten In reply to
'FieldName' is the name of your database ID field. (JPD, maybe this should be clarified in the txt file?)

If your counter is working fine, then you need to make sure both the counter MOD and Top Ten MOD are looking in the same place. Obviously, if your temp directory is empty, then you're storing your counter files in a different location. Smile Get those two sync'ed, and let us know what happens.

--Lee
Quote Reply
Re: Top Ten In reply to
K, UserID is my FieldName, so that's right. My counter (separate site) looks like this:
Code:
$count_up= "/home/m/u/murgnam/www/cgi-bin/dbman/temp/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;
However, the Top Ten Mod and what I have currently (dummy site) has it like this:
Code:
$count_up= "$counter_dir/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;
The difference I see is the reference to absolute path in the first one, not in the second one. If I simply replace $count_up= "$counter_dir/$rec{$db_key}"; with $count_up= "/home/m/u/murgnam/www/cgi-bin/dbman/temp/$rec{$db_key}"; that mutes the whole ref to counter_dir in the default.cfg
Alas, I'm still confused, *sigh*
JR
Quote Reply
Re: Top Ten In reply to
You can check your config to see what $counter_dir is set to, and make sure that matches what $count_up in the count MOD is set to. However, there is an easier way.

Just copy the counter MOD's $count_up line and replace the one in the top ten MOD. If they're both exactly the same, then it should work.

Let me know if that works. Smile

--Lee
Quote Reply
Re: Top Ten In reply to
Good News: I think I've got it working.

Bad News: The ten UserID's shown all have only "1" hit, there's plenty others with more that 1 that should be shown, :-0.

2 more things:

1. It displays in a row, can I have it displayed as a column?
2. The UserID in my db is hidden. I'd much rather have Last Name than UserID, is that possible?

JR

Quote Reply
Re: Top Ten In reply to
The "FieldName comment" in the mod is as follows:

Quote:
# If you're using the short/long display mod, instead of

&html_record(&get_record($toplist));

# use

%rec = (&get_record($toplist));
print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&view_records=1&ww=1">
$rec{'FieldName'}</a>
|;

# Change $rec{'FieldName'} to match your database.

I don't know how to clarify this. It is the field that you want to show up in your link to the record. What should I say? I am putty in your hands.

If you want the last name to show up, use

$rec{'LastName'} or whatever the name of the field is in your database.

If you want both the first name and last name to show up, use

$rec{'FirstName'} $rec{'LastName'} or whatever the names of the fields are in your database.

I really don't know how I can say things so that they apply to everyone. I truly am open to suggestions.

As to the other problem, I don't know what's wrong.

------------------
JPD








[This message has been edited by JPDeni (edited May 04, 2000).]
Quote Reply
Re: Top Ten In reply to
JPD,

Told ya it was a bonehead question, appears I was reading too much into it. I've currently got
Code:
<a href="$db_script_link_url&$db_key=$rec{$db_key}&view_records=1&ww=1">$rec{'Last Name in School'}</a>
$rec{'Married Name'} $rec{'First Name (Nickname) & Spouses Name'} $rec{'YearGrad'}<BR>|;
in that line, but I'm still tinkering.

Above said, with my tinkering, I've come to realize the top ten is, in-fact, working! It's sorting and displaying the records with the most hits.

The problem, somehow, is that when I click on said record from the top ten, the html record_long states the record has been hit 1 times, when, in-fact, it's been hit 9 times -- verified by me looking at the temp directory.

So something must still be amiss with the "count" part in the html_long. All I did to the long display was include:
Code:
<TR><TD COLSPAN="50%">This record has been hit:</TD>
<td COLSPAN="50%"><b>$countup2</b> times.</td></tr>

Over

JR
Quote Reply
Re: Top Ten In reply to
I'm glad that got cleared up. Smile

In sub html_record_long, you should have

Code:
$count_up= "$counter_dir/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;

in addition to

Code:
<TR><TD COLSPAN="50%">This record has been hit:</TD>
<td COLSPAN="50%"><b>$countup2</b> times.</td></tr>

Is that what you have?


------------------
JPD






Quote Reply
Re: Top Ten In reply to
JPD,

It's fixed! The answer was being in the right place at the right time. I had
Code:
sub html_record_long {
#----------------------------------------------------------------
my (%rec) = @_;
$count_up= "/home/m/u/murgnam/www/cgi-bin/dbman/temp/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;
$rec{$db_key} =~ s/<.?B>//g;
if ($db_total_hits > 1) {
which I just changed to
Code:
sub html_record_long {
#----------------------------------------------------------------
my (%rec) = @_;
$rec{$db_key} =~ s/<.?B>//g;

$count_up= "/home/m/u/murgnam/www/cgi-bin/dbman/temp/$rec{$db_key}";
open (COUNT, "<$count_up");
$countup = <COUNT>;
close COUNT;
open (COUNT, ">$count_up");
$countup2 = $countup + 1;
print COUNT $countup2;
close COUNT;

if ($db_total_hits > 1) {
and voila!

Thx for listening, I "think" I'm on target again, top ten is good, count is good! Time for a smoke, ahhhh!

JR