Gossamer Forum
Home : Products : Links 2.0 : Customization :

Need help with monthhits

Quote Reply
Need help with monthhits
Hi

I need some help with monthhits.
In the mod it says:
"Also, you're going to need to clear out the monthhits field for every month period, so you'll need this:"

Is that a new file, I should create? What name shall I give it? And where do I put it?

Regards
Kirsten Olsen
Denmark
http://www.hunde-portalen.dk



Quote Reply
Re: Need help with monthhits In reply to
copy the code below and put it in your admin folder. I called my eommhits.cgi. CHMOD to 755. I run mine on the last day of each month. I run the Build All just before this. I run it from my browser.

Remember to back-up the data folder.

Code:
#!/usr/bin/perl
# -------------------------------------------
require "/home/yourpath/cgi-bin/links/admin/links.cfg"; # Change this to the path to your links.cfg
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "$db_links_name")
or print "Unable to open links database 'links.db'. Reason: $!" and exit;
open (DBOUT, ">$db_links_name.bak")
or print "Unable to open output database. Reason: $!" and exit;
LINE: while (<DB> )
{
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@RecOut = &split_decode($_);
$RecOut[$db_monthhits] = 0;
print DBOUT &join_encode(&array_to_hash(0, @RecOut));
}
close DB;
close DBOUT;
print "\nLinks database now has monthhits field reset.\n\n";

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB>) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}
Gene
Quote Reply
Re: Need help with monthhits In reply to
Thanks:-)

Now I have done all the mods, but there is a "little" problem:
When I click on "Top-Link" I only get the Monthshits. Any suggestions on, what went wrong for me? And how I can get to display the allover POP?

Regards
Kirsten Olsen
Denmark
http://www.hunde-portalen.dk

Quote Reply
Re: Need help with monthhits In reply to
In Reply To:
When I click on "Top-Link" I only get the Monthshits. Any suggestions on, what went wrong for me?
I don't remember any "Top-Link" in Monthshits. Can you provide more infomation?


In Reply To:
how I can get to display the allover POP?
Not sure what you are asking for here. Can you provide more infomation?

Smile

Gene
Quote Reply
Re: Need help with monthhits In reply to
Okay, Top-Link is a danish translation:-)

When I click on "Whatīs cool" I only get the monthhits.

I have noticed, that the script donīt make the MonthCool/index.shtml- file.

Hope You understand my english now:-)

Kirsten Olsen

Quote Reply
Re: Need help with monthhits In reply to
your english is fine....better than my Danish....just need more detail

I remember now....had to check my MOD folders for this MOD.

I had the same problem.....I ended up copying the sub build_cool_page and replacing the COOL with MONTHCOOL

Here is what mine looked like

Code:
#monthly hits mod modded
sub build_monthcool_page {
local ($total, $percent, $link_results, $title_linked);
my (%link_output, $category_clean);
if ($build_monthcool_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
CATEGORY: foreach $category (sort keys %monthcool_links) {
LINK: for ($i = 0; $i < ($#{$monthcool_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$monthcool_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
}
}
foreach $category (sort keys %monthcool_links) {
$category_clean = &build_clean ($category);
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
}
$title_linked = &build_linked_title ("MonthlyCool");
open (MONTHCOOL, ">$build_monthcool_path/$build_index") or cgierr ("unable to open what's Monthcool page: $build_monthcool_path/$build_index. Reason: $!");
print "\tMonthly Cool-Hot Links: $total\n";
($db_monthpopular_cutoff < 1) ?
($percent = $db_monthpopular_cutoff * 100 . "%") :
($percent = $db_monthpopular_cutoff);
# forgot to change to the site_html_monthcool html but no biggie
print MONTHCOOL &site_html_cool(@monthcool_links); Hmmm...maybe you should change yours to &site_html_monthcool
close MONTHCOOL;
}
Gene
Quote Reply
Re: Need help with monthhits In reply to
Gene,

You did pretty much the same thing I did...

A couple of weird things happened though.

Categories ends up being the number of hits. When I cut and pasted your
build_monthcool subroutine in, I ended up with a bunch of numbers where
the categories are on the cool pages. They're the number of hits that each
link has for the month. That's fine, though I did have to modify it so that
they no longer look like a link.

However, they don't sort correctly. It's treating them as text, rather than
as a number. So you end up with hits like 100, 2, 37, 4, 5, 52, 6...

How can I get it to sort on the hits numerically?