Gossamer Forum
Home : Products : DBMan : Customization :

Top Ten List Mod

Quote Reply
Top Ten List Mod
JP, LouisC...

I added the top ten list mod and can't figure out how I'm supposed to get the variable $countup2 to display - I printed something like, "This record has been displayed &countup2 times.", but what prints is "This record has been displayed times.".

Any ideas?

Thanks,

Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
From the mod:


# When you are defining the structure of the page layout, wherever
# you want to show the number of hits made to the record, simply
# reference $countup2.


If that's what you have, then I'll have to see what code you have before the line where you're printing out the number of accesses.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
yea, that's what I've got...here's the code:

In sub html_view_success {:


<blockquote>
<p><$font>
|;
if ($db_total_hits == 1) {
print "Your search returned $db_total_hits match. This route has been displayed $countup2 times.";
}
else {
print "Your Search returned $db_total_hits matches. This route has been displayed $countup2 times.";
}

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

# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}




Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
From the mod:

Code:
# In sub html_record (or sub html_record_long, if you're using the
# short/long display mod), after

my (%rec) = @_;

# add

$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;
I the code you posted, the $countup2 variable has not yet been defined. It cannot be defined for more than one record.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
Okay, there went my eyes again! Sorry must have missed that part. I'm going to go make an appointment with my optomotrist for an eye-exam and a new pair of glasses. Tongue Thanks for having better eyes than I do.

I've also come across another problem with another MOD. =-/

The What's New MOD, found on the last page of the resources section on this site, is giving me problems. Whenever I click on the "What New" link in the footer, it brings me to the "Search Failed" (sub html_view_failure) no matter what. Seems like the database is completely ignoring the listnew=1 command in the address bar of my browser because when I take out the view_records=1 in the address bar, and only leave the listnew=1, it gives me the unknown action page. Ideas?

Thanks again,

Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
Did you add the code to sub query?

Code:

if($in{'listnew'}) {
$days = 6; # Number of days for What's New, +1.
$new = &get_date(time() - ($days * 86400));
$in{'Date-gt'} = $new;
$in{'sb'} = 2; # Number of your date field
$in{'so'} = 'descend';
}
You say you always get a "Search Failed" page. What is the message on the page?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
Yea, I've got it in there. I think I've spotted the culprit line:

$in{'sb'} = 2; # Number of your date field

I didn't see this line until I made sure the code I had was the exact same as the code you showed me (which it is). I'm not quite sure what this line means.

Also, in reply to your question about what the page displays; I get the following error message: "I had problems finding a route because: no search terms specified".


Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
$in{'sb'} = 2; # Number of your date field

is the number of the field that holds the date the record was added. Change 2 to match the number of the field.

If you're getting "no search terms specified" then you're having a problem getting the date entered into the field.

You may need to change

$in{'Date-gt'} = $new;

to match the name of your field. If your date field is called date then change the line to

$in{'date-gt'} = $new;

It has to match.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
In Reply To:
$in{'sb'} = 2; # Number of your date field

is the number of the field that holds the date the record was added. Change 2 to match the number of the field.
Okay, that makes more sense.

In Reply To:
You may need to change

$in{'Date-gt'} = $new;

to match the name of your field. If your date field is called date then change the line to

$in{'date-gt'} = $new;

It has to match.
Okay, that was one bug knocked out - I have two date fields: one saying "Added:" and another saying "Last Updated:"; I use the Added one so I changed $in{'Date-gt'} = $new; to $in{'Added-gt'} = $new;.
Is that right?

Also, I found another problem - if you have no records, it doesn't display a screen saying "No new records" or something to that effect; it shows you that "search failed" screen. Would it be possible to show a page saying "No new routes have been added in the last 30 days." if no new routes are added within those thirty days instead of the "Search Failed" screen?
I think it might be possible if you put something like this: First, in the sub html_view_failure, determine if or if not 'listnew' is in the query string. Then, if not, continue through the current subroutine. And if so, then quit this subroutine and go to a new one (possibly sub html_no_new) which prints "No new routes have been added in the last 30 days."

Thoughts?

Thanks,


Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
In Reply To:
I use the Added one so I changed $in{'Date-gt'} = $new; to $in{'Added-gt'} = $new;.
Right.

In Reply To:
I think it might be possible if you put something like this: First, in the sub html_view_failure, determine if or if not 'listnew' is in the query string. Then, if not, continue through the current subroutine. And if so, then quit this subroutine and go to a new one (possibly sub html_no_new) which prints "No new routes have been added in the last 30 days."
Sounds good.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
I went and played around with the idea and can't figure out how I would determine whether or not listnew is in query string. If I used the following

sub html_view_failure {
# --------------------------------------------------------
# The search for viewing failed. The reason is stored in $message
# and a new search form is printed out.

$ListNew = $ENV("QUERY_STRING");

if( $ListNew == 1) {
&ListNewFailed;
exit;
}
else {

my ($message) = $_[0];

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Search Failed</title>
....
}

Would it work?

Thanks,


Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
Just use

if ($in{'listnew'}) {


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
Thanks - haven't ever tried to use QUERY_STRING stuff before (just a beginner). I used the following code, but to no avail. Here it is:
Code:

sub html_view_failure {
# --------------------------------------------------------
# The search for viewing failed. The reason is stored in $message
# and a new search form is printed out.

Code:


if ($in{'listview'}) {
&html_no_new;
exit;
}
else {


my ($message) = $_[0];

&html_print_headers;
print qq|
<html>
<head>

....

</table>
</center>
</form>
</body>
</html>
|;
}
}

And the new subroutine:
Code:

sub html_no_new {

# --------------------------------------------------------
# This displays if the user has clicked the "What's New"
# link but there were no new entries to be shown.
# --------------------------------------------------------

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: No New Entries</title>

...

<P><$font>$db_userid, I'm sorry but there hasn't been any entries into the database in the last thirty days. Please check back later; maybe you'll have better luck then.</FONT><P>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}

It's still showing the "Search Failed" screen. Any ideas?

Thanks,


Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
if ($in{'listnew'}) {[/blue]

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
Thanks JPD....I can't believe I missed that Frown
Like I said earlier, you can tell I'm getting better at this, right? LOL.

Thanks,


Michael DeLong
Quote Reply
Re: Top Ten List Mod In reply to
It happens. Smile

You had an understanding of what code to use and where to put it. That's more than a whole lot of people have. Smile


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Top Ten List Mod In reply to
Aw, shucks. Blush
Thanks, you made me feel better. Smile


Michael DeLong