Gossamer Forum
Home : Products : Links 2.0 : Customization :

Top 10 on home page by number of visits

Quote Reply
Top 10 on home page by number of visits
Hi

I know this has been answered again and again but I need to know step by step how to put top 10 sites on main page by number of visits without using SSI? (i'm using links 2.0 & templates) Please help... i'll be REALLY thankful. I was trying to follow this thread http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/002409.html but got lost.
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Replace your site_html_home in site_html_templates.pl with:
Code:
sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.
my (@data,%tophits,%name,%url);

open (NAME,"<$db_file_name");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$topsites_output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}


return &load_template ('home.html', {
topsites_output => $topsites_output,
category => $category,
grand_total => $grand_total,
%globals
});
}

Then in home.html, put <%topsites_output%> wherever you want the info.

------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
THANKX A MILLION CEGlobe!!!! It's working!!!! but I noticed that instead of using the jump cgi the links are coded with real urls...

can u please make the links coded with the jump.cgi?ID=xxx because i don't want people to be looking at the real urls!!! This is only change i need... the rest is absolutely fine!!

Thanks again! I really appreciate your help!

Deep Impact
Quote Reply
Re: Top 10 on home page by number of visits In reply to
change:
<a href=\"$url{$field}\">

to:

<a href=\"/path/to/jump.cgi?ID=$field\">

------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
THANKS!!! It's working just as i wanted it to Smile

Deep Impact
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Hi,

Can this same change be applied to the e-mail so that when this is sent it will go to the link via jump, rather than showing the URL in the e-mail

Thanks
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Hi !!!

Great job Ceglobe !!!

But there is a problem .... the mod shows the links in a random order ...

like this :

1. Jonas ( 1 hits)
2. Carlos ( 3 hits)
3. Joaquim ( 10 hits)
4. Zeca ( 8 hits)
5. Tatu ( 6 hits )

when the correct should be :

1. Joaquim ( 10 hits)
2. Zeca ( 8hits)
3. Tatu ( 6 hits)
4. Carlos ( 3 hit)
5. Jonas ( 1 hit )

Please, can someone help me to fix this ???

Regards,

Marco Aurélio

Quote Reply
Re: Top 10 on home page by number of visits In reply to
I have installed the Top 10 on all of my pages except, category, rate_top, new, cool, and search results. Everything is working great except I have added a new file in my templates. It builds the template fine, but it is prints the top 10 twice. The page does not building any links on it as in category, search results, etc. Any ideas on what I have done wrong? Here is the code in the site_html_templates.pl
Code:
sub site_html_rate_info {
# --------------------------------------------------------
# Rate Info File
my (@data,%tophits,%name,%url);

open (NAME,"<$db_file_name");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$topsites_output .= "$count. <a href=\"http://www.homewithgod.com/cgi-homewithgod/links/jump.cgi?ID=$field\">$name{$field}</a><br>\n";
}
$count++;
}


return &load_template ('rate_info.html', {
topsites_output => $topsites_output,
%globals
});
}

BTW Thanks, CEGlobe and Eliot for the Mod and instructions on top 10 and adding new templates!

------------------
Jimmy Crow
www.homewithgod.com
webmaster@homewithgod.net


[This message has been edited by jcrow (edited March 18, 2000).]
Quote Reply
Re: Top 10 on home page by number of visits In reply to
The problem is that you have hacked the codes too much and with the current definitions you have, it will not work.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
yeah I tried a lot of different things to make it work. I guess I'm not clear on what you would use the extra templates for. Would they only be used for calling simple tags like <%category%>, <%query%>, etc. ? Is the only way to call <%topsites_output%> by inserting it on a template in the templates file without doing a lot of modification to the code?

Thank you for your time Smile

------------------
Jimmy Crow
www.homewithgod.com
webmaster@homewithgod.net


[This message has been edited by jcrow (edited March 18, 2000).]
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Yes....try the following:

1) Add a sub-routine called sub top_ten in the site_html_templates.pl:

Code:
sub top_ten {
#-------------------------------------------
# Insert Top Ten Sites

open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");

LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}
return $output;
}

2) Then define a global tag called topsites in the %globals hash in the site_html_templates.pl file:

Code:
topsites => &top_ten

3) Add the following tag in whatever template file you want the top ten to show up in:

Code:
<%topsites%>

That should do it.

Regards,



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


[This message has been edited by AnthroRules (edited March 18, 2000).]
Quote Reply
Re: Top 10 on home page by number of visits In reply to
YES! That works perfect and on the first try! Am I correct to assume that this can only be used in files that are in your template directory and not on pages I have made and uploaded in the Links/Pages directory. This did exactly what I wanted it to do. You never cease to amaze me at how fast you can write these codes. Thank you very much.



------------------
Jimmy Crow
http://www.homewithgod.com
webmaster@homewithgod.net
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Ok Guys ,

This mod run perfectly, but don't match the order to links that have more hits ... why ???

Take a look in my post above ...

Any suggestion, Eliot, Jimmy ???

Thanks,

Marco Aurélio
Quote Reply
Re: Top 10 on home page by number of visits In reply to
jcrow,

Code:
#!/usr/local/bin/perl
# Script for putting Top Ten Sites in other LINKS associated pages.
# Change the permission of this script to 755.
# Change the path to the links.cfg file if you need to.
# Use it in the following manner:
# <!--#exec cgi="/cgi-bin/links/topsites.cgi"--> in SSI capable
# pages.
###########################################################
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script locatio
n: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script locatio
n: Windows \

require "admin/links.cfg"; # Change this to full path to links.c
fg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set
correctly.";
exit;
}
#========================================================
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}
return $output;
}

Then add the following codes in your SSI enabled pages:

Code:
<!---#exec cgi="/cgi-bin/links/topsites.cgi"-->

Regards,





------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
marcoBR,

Your problem is that you need to change the field numbers for the following variable configs:

Code:
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];

Translations:

$tophits -> You need to change [8] to the number of your Hits field.

$name -> You need to change [1] to the number of your Title field.

$url -> You need to change [2] to the number of your URL field.

Most likely you do not have the correct field numbers for these variables, which is screwing up the sorting.

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
marcoBR
I currently have both of these mods installed, CEGlobe's works fine on all pages except where it builds links. And they are in order. Eliot's version works fine on All of the pages including those that builds links. Have you tried installing his version? It is pretty simple and takes a few minutes. You must have copied something incorrectly in CEGlobes because it is working here or, I'm not real smart at this, but you might check your sorting fields. Someone will probably come and correct me, but that is where I would look if both versions are not working.

------------------
Jimmy Crow
http://www.homewithgod.com
webmaster@homewithgod.net
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Hey thanks a lot Eliot, the stand alone pages was what I was referring to in my last statement. I am currently changing my site to blend in with my links design and was thinking that I would have to make templates for all of the pages. This will save me MANY hours work! Smile

Jimmy

------------------
Jimmy Crow
http://www.homewithgod.com
webmaster@homewithgod.net
Quote Reply
Re: Top 10 on home page by number of visits In reply to
YEAH !!!

Now all is working perfectly !!!

Thanks Eliot and Jimmy ...

Marco Aurélio
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Good for both of you...Glad it is working for you both.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
jcrow,

BTW: If you want to use the jump.cgi file (which I personally would not recommend since people could just continually click on the Top Sites therefore leaving a static list of "top sites") in this Mod, just do the following:

1) Add the following codes:

Code:
$id{$data[0]} = $data[0];

AFTER the following codes:

Code:
$tophits{$data[0]} = $data[8];

2) Then edit the following line of codes:

Code:
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";

to look like the following:

Code:
$output .= "$count. <a href=\"$build_jump_url?ID=$id{$field}\">$name{$field}</a><br>\n";

Again, I would recommend NOT using the jump.cgi, because the Top Ten could become biased and scewed.

Regards,

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


[This message has been edited by AnthroRules (edited March 18, 2000).]
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Very Good !!!

Is it possible to include new output fields like description, images, etc ... in this mod ??

-> Here: $output .= "$count. <a href=\"$build_jump_url?ID=$id{$field}\">$name{$field}</a><br>\n";

Any ideas?

Regards,

Marco Aurélio
Quote Reply
Re: Top 10 on home page by number of visits In reply to
uh...yeah...think out of the box (codes), please...

Look at the relationships of the codes I posted and the Mod...see anything that sticks out when I added the jump.cgi option???

Come on, people...let's think a little here. The codes you need are right in front of you.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Is it possible to limit the number of characters in the titles of the tpo ten on the home page without affecting the title in the rest of links. I am putting the top 10 on my hompepage in a fairly narrow table and as it is now, some of the titles take up 2 and 3 lines.

------------------
Jimmy Crow
www.homewithgod.com
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Code:
$title = substr($title,0,8) . "..." if (length($title) > 8);

Try the above codes. These will work with your "title" variable. Change $title to whatever you are using in this Mod.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Thank you for all your help on this. I have tried inserting the code in 4 different places in between open and close name and in the output area. I appoligize for knowing, but I'm still a rookie. When you have a chance could you point me where it goes.

------------------
Jimmy Crow
www.homewithgod.com
Quote Reply
Re: Top 10 on home page by number of visits In reply to
*sigh*

Try putting the codes I gave you after the following codes:

Code:
$url{$data[0]} = $data[2];

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
That was one of my guesses. It doesn't work there. This is the way I have it.
Code:
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
$name = substr($name,0,8) . "..." if (length($name) > 8);
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}
return $output;
}

I also tried commenting out

$name{$data[0]} = $data[1];

but is still had the same results. Thanks for the effort Do you have any other ideas? I have it on all my pages, but if I have to I can place it somewhere else on the homepage and take it off the rest of the pages. The way it is now it forces the table wider and distorts the rest of the page.

------------------
Jimmy Crow
www.homewithgod.com
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Well, what you can do as a quick fix is use a nested table for this script, then the text will wrap around rather than expanding the main table column. (This is a quick and dirty solution...plus truncating titles does not always serve end users very well.)

So, put the link codes in the stand alone script codes I gave into a nested table. Do I need to explain how to write nested table HTML codes?

Regards.

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Don't know why I hadn't thought of that.
Thanks for the script and help.

------------------
Jimmy Crow
www.homewithgod.com
Quote Reply
Re: Top 10 on home page by number of visits In reply to
You're welcome.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Is it possible to define my top 10 in the link.html template ? Look this:

Instead ...
-----------------------------
<%if isPop%>
<sup><b>Top 5</b></sup>
<%endif%>
-----------------------------

change to ...
-----------------------------
<%if topten%>
<sup><b>Top 10</b></sup>
<%endif%>
-----------------------------

Any ideas ???

Regards,

Marco Aurélio
Quote Reply
Re: Top 10 on home page by number of visits In reply to
That would not be as easy as you have suggested. It would take a lot of work to do this...you would have to do the following:

1) Add another field called isTopTen (refer to the FAQ in the Resource Center on adding links to your links.def and links.db file).

2) Then the sub build_stats routine in the nph-build.cgi file would have to be edited...which I am unsure about how to do at this point.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Ok Eliot ...

I have a sub_topfive and sub_topten in my site_html_templates.pl , but when I call the <%topten%> too is showed the topfive links thus:

1. Una Componentes
2. Cinex Componentes e Acessórios
3. Verdasca
4. Palito
5. zica
1. Una Componentes
2. Cinex Componentes e Acessórios
3. Verdasca
4. Palito
5. zica
6. Muvuca
7. tito
8. Teste - Modify2
9. zeca
10. Muvuca 4 A Demoliçăo!


How can I solve this problem ???

... and is it possible to include 0 in the count ? thus: 01 instead 1 ... ok

Regards,

Marco Aurélio
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I really don't know...How have you set the numbers for the if ($count <= 10) {.

For the Top Five Sub, these codes must be:

Code:
if ($count <= 5) {

AND you have to use separate tags:

<%top_five%>
<%top_ten%>

To change 1 to 01, TRY changing the following codes:

Code:
my $count=1;

to the following:

Code:
my $count=01;

TRY = no gaurantee.

And Marco...please consider buying a Perl book, so that you can learn some Perl, which will allow you to customize your scripts!

Wink

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Hi,
I applied the first top10 code to my site_html_templates and works ok.

I have attempted the second code and the cgi doesn't work
I have edited the path of the links.cfg and it doesn't work.
What can it happen?

[an error occurred while processing this directive]

topsites.cgi 755
transfer in ascii
path of the links.cfg : /home/sites/mysite/web/cgi-bin/links/admin/links.cfg




On the other hand, I would like to make the following thing:

Most visited site:
Yahoo

Without the top10 numeration.
1. Yahoo

Is this possible?

Thanks.




------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
For taking out the number...simply delete $count. out of the following codes:

Code:
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";

For the SSI problem, you may have to use the following codes:

Code:
<!--#include virtual="/cgi-bin/links/topten.cgi"-->

Rename the paths to your top ten script is located. Also change the name of the file.

If this doesn't work...guess what...you do not have SSI enabled.

Smile

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Top 10 on home page by number of visits In reply to
It show my top 10 sites in this format:
1.name
2.name

I need:
1. name (hits rating)
description

how?
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Man,

You people really need to learn Perl or at least take the time to see what the codes do and may be you can figure it out for yourself!!!!

ANYWAY...this is the last Reply I will add to this Topic...you guys and gals are on your own (get a Perl book or at least familarize yourself with the codes that you copy and paste from these Forums!).

To add the Hits and Ratings and Description, you need to add the following codes in the codes already provided above:

Code:
$descrip{$data[0]} = $data[3];
$hits{$data[0]} = $data[7];
$rating{$data[0]} = $data[8];

Change 3, 7, and 8 to the number of the fields that correspond to your Description, Hits, and Rating field.

Then add the following codes:

Code:
$descrip{'field'}
$hits{'field'}
$rating{'field'}

in the following line of codes:

Code:
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Last Question:
Im add your code,but it again not working.
My code:
sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.
my (@data,%tophits,%name,%url);
open (NAME,"<$db_file_name");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);

$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];

$descrip{$data[0]} = $data[3];
$hits{$data[0]} = $data[7];
$rating{$data[0]} = $data[9];

$descrip{'field'}
$hits{'field'}
$rating{'field'}

}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$topsites_output .= "$count. <a href=\"$db_cgi_url/jump.cgi?ID=$field\">$name{$field}</a><br>\n";
#$topsites_output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
#$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}

return &load_template ('home.html', {
topsites_output => $topsites_output,
category => $category,
grand_total => $grand_total,
%globals
});
}
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Roman....

You are using the WRONG codes...

These codes need to be deleted:

Code:
$descrip{'field'}
$hits{'field'}
$rating{'field'}

And for the jump.cgi script you have to work, you need to pull the ID field...which you have not done...you have to add the following codes:

Code:
$id{$data[0]} = $data[0];

AFTER the following codes:

Code:
$rating{$data[0]} = $data[9];

And you need to replace the jump.cgi link that you have with the following:

Code:
<a href=\"$db_cgi_url/jump.cgi?ID=$id{'field'}\">$name{$field}</a>

Except as I mentioned before...why would you want to have jump.cgi for the link in the Top Ten site...if you do, you risk the chance of having a static list of links since people will just keep clicking on the Top Ten sites...

But to each his/her own.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
Im change coge but and now it have old style:
1.some
2.some

changed code:

sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.
my (@data,%tophits,%name,%url);
open (NAME,"<$db_file_name");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);

$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];

$descrip{$data[0]} = $data[3];
$hits{$data[0]} = $data[7];
$rating{$data[0]} = $data[9];
$id{$data[0]} = $data[0];

}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$topsites_output .= "$count. <a href=\"$db_cgi_url/jump.cgi?ID=$id{'field'}\">$name{$field}</a><br>\n";
#$topsites_output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
#$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";
}
$count++;
}
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Okay...private email did not work...

Roman...again you are using the WRONG codes...

Do the following (and I really hope you get it this time, and a word of advice...get the default codes working before hacking it to fit your needs)....

1) Take out the # signs before the second and third code lines that contains $topsites_output.

2) Put in the following codes (which are the most crucial and included with the default Mod codes):

Code:
return $topsites_output
}

AFTER

Code:
count++;
}

I REALLY hope you get it!

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.




[This message has been edited by AnthroRules (edited April 16, 2000).]
Quote Reply
Re: Top 10 on home page by number of visits In reply to
oh,sorry,im changed email,but gorget replace it here,now is correct.
I can`t find correct code Frown
Quote Reply
Re: Top 10 on home page by number of visits In reply to
In the last Reply I gave, I provided the codes you need to use!!!

READ IT AGAIN!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
I want to use tables in my top 10 links,but it wount working when I incerrt my code:

# Insert Top Ten Sites
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$id{$data[0]} = $data[0];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
$descrip{$data[0]} = $data[5];
$hits{$data[0]} = $data[6];
$rating{$data[0]} = $data[9];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <TABLE bgColor=#ffffff border=0 cellPadding=0 cellSpacing=0 width="100%">

<TR>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">

<TR>
<TD><FONT face="Arial, Verdana" size=2><B><a href=\"$build_jump_url?ID=$id{$field}\">$name{$field}</a></B></FONT>
</TD></TR>
<TR>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 height=1 width="100%">

<TR>
<TD bgColor=#808080 vAlign=bottom width="100%"><IMG border=0
height=1 hspace=0
src="/images/blackdot.gif"
width=1></TD></TR></TABLE></TD></TR>
<TR>
<TD bgColor=#ffffe8><FONT face="Verdana, Arial" size=2>$descrip{$field}</FONT></TD></TR>
<TR>
<TD><FONT color=#000000 face="Arial, Verdana"
size=1><B>Category:</B></FONT></TD></TR>
<TR>
<TD height=10></TD></TR>
<TR><br>\n";
}
$count++;
}
return $output;
}

error message from links:
Error including libraries: syntax error at /cgi-bin/admin/site_html_templates.pl line 164, near ""$count. " syntax error at /cgi-bin/admin/site_html_templates.pl line 183, near "<" syntax error at /cgi-bin/admin/site_html_templates.pl line 465, near "}" Make sure they exist, permissions are set properly, and paths are set correctly.

What is wrong in my codes?
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Try adding the following operators in your codes:

qq| and |;

So, the table codes should look as follows:

Code:
$output .= qq|$count. <TABLE bgColor=#ffffff border=0 cellPadding=0 cellSpacing=0 width="100%">

<TR>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">

<TR>
<TD><FONT face="Arial, Verdana" size=2><B><a href=\"$build_jump_url?ID=$id{$field}\">$name{$field}</a></B></FONT>
</TD></TR>
<TR>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 height=1 width="100%">

<TR>
<TD bgColor=#808080 vAlign=bottom width="100%"><IMG border=0
height=1 hspace=0
src="/images/blackdot.gif"
width=1></TD></TR></TABLE></TD></TR>
<TR>
<TD bgColor=#ffffe8><FONT face="Verdana, Arial" size=2>$descrip{$field}</FONT></TD></TR>
<TR>
<TD><FONT color=#000000 face="Arial, Verdana"
size=1><B>Category:</B></FONT></TD></TR>
<TR>
<TD height=10></TD></TR>
<TR><br>\n|;

Hope this helps.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
Hi,
SO I installed the mod, and it's working fine!!! But still, I have a question
... As I show it on http://www.surfootball.ovh.org/example.htm , I'm trying to
change the layout of the thing... could somebody please help,
Smile

THEULS

------------------
----------------------
Surfootball.ovh.org
----------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Yea...

1) Be more specific of HOW you want to change the layout.

-AND/OR-

2) Read this TOPIC more carefully...because there are codes that allow different layouts.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
For the number of visits, I did without too much problem... Now, how can we xhange the background
of each links (as seen at http://surfootball.ovh.org/example.htm) ????
Thanx
Smile)

THEULS

------------------
----------------------
Surfootball.ovh.org
----------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
 Actually, I have another problem.... When I modify this line for the font colors...:

$topsites_output .= "$count. <a href=\"$url{$field}\">$name{$field}</a> ( $hits{$field} passages)<br>\n";
I get a nphbuild error.Here is what I tried:

$topsites_output .= "$count. <font face="Arial" size="2"><a href=\"$url{$field}\">$name{$field}</a> ( $hits{$field} passages)</font><br>\n";

$topsites_output .= "$count.<a href=\"$url{$field}\"font face="Arial" size="2">$name{$field}</a> ( $hits{$field} passages)</font><br>\n";

and all sorts of combinations, but none of them worked....
Frown

THEULS

------------------
----------------------
Surfootball.ovh.org
----------------------
Quote Reply
Re: Top 10 on home page by number of visits In reply to
You need to use one of the following codes:

Code:
$topsites_output .= qq|$count. <font face="Arial" size="2"><a href="$url{$field}">$name{$field}</a> ( $hits{$field} passages)</font><br>\n|;

-OR-

Code:
$topsites_output .= "$count. <font face=\"Arial\" size=\"2\"><a href=\"$url{$field}\">$name{$field}</a> ( $hits{$field} passages)</font><br>\n";

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
I have looked and looked for Directions on how to place the top 10 sites on my home page,
But I can't seem to find an simple set of instructions.

Is there a URL or a place where I can get this, I would like to set up a Top 10 sites on my main page.
I have check the resouces, but the file is incomplete, starts at insturction 4.

Any help would be appreciated.
Thanks John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
Look on Page 2 of this Thread...I have posted codes about three times for doing this via SSI and also through the nph-build.cgi build process. Look again!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Thank you, i missed that.

I have installed but I am getting this error.

[an error occurred while processing this directive]

I am using this Call in stead of !--#exec cgi=" My understand it it works the same.

!--#include virtual="/cgi-bin/admin/topten.cgi"--


Here is the code for the topten.cgi

#!/usr/local/bin/perl
# Script for putting Top Ten Sites in other LINKS associated pages.
# Change the permission of this script to 755.
# Change the path to the links.cfg file if you need to.
# Use it in the following manner:
# in SSI capable
# pages.
###########################################################
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.

require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
#========================================================
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
\n";
}
$count++;
}
return $output;
}



I set permissions to 755, and I still get the error.

Any Idea's

Thanks.
John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
The script NEEDS to be outside a password protected directory. I am assuming that your admin directory is password protected.

Put the cgi script in your cgi-bin directory and then change the SSI call you have to the following:

Code:

!--#include virtual="/cgi-bin/topten.cgi"--


If this SSI call doesn't work after moving the topten.cgi script, then try the following SSI call:

Code:

!--#exec cgi="/cgi-bin/topten.cgi"--


Remember that you have to add < at the front and > at the end of these SSI calls.

If neither of these SSI call codes work, then your server probably has something misconfigured that does not allow SSI calls.

BTW: You also need to change the following codes:

Code:

require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.


to the following:

Code:

require "/absolute/path/to/cgi-bin/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.


Change /absolute/path/to/ to your COMPLETE (full) path in your server.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I tried all that and it still does not work.

All my other SSI works fine.

I use itfor WebAdvers.
And some Text Calls.

And it worlks fine.

Any other Ideas.....

John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
Yea...copy your topsites.cgi script as a text file and upload it to your web server in a publicly accessible directory. Do the same for your current version of the web page you are using the SSI call in.

Then post the URL to these text files.

I betcha you are not using the complete codes and that you are not using the correct SSI call! Wink

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Thanks,

Here is where I put the files.

http://www.incomemax.com/links/

Quote Reply
Re: Top 10 on home page by number of visits In reply to
Uh...I got an error message when I tried to look at your topten.cgi file...SAVE it as topten.txt!!!!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Done. I has been changed.


John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
Welp...I looked over your file and there does not seem to be any syntax errors...

I would double check the following:

1) Perl path (first line of the file).
2) Permission of the file (755).

Other than that...I don't know what to tell ya.

Best of luck!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I've installed your code on calling the top 10 site list onto a seperate (other than links) page via ssi code but I'm getting an error that I can't figure out for the life of me.

Unmatched right bracket at ...cgi-bin\links\topsites.cgi line 46, at end of line syntax error at ...cgi-bin\links\topsites.cgi line 46, near "}" Execution of ...cgi-bin\links\topsites.cgi aborted due to compilation errors.

Here's my code:

#!/usr/local/bin/perl
# Script for putting Top Ten Sites in other LINKS associated pages.
# Change the permission of this script to 755.
# Change the path to the links.cfg file if you need to.
# Use it in the following manner:
# in SSI capable
# pages.
###########################################################
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
#========================================================
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
\n";
}
$count++;
}
return $output;
}

I can't find any difference between the above and what you wrote. Can someone please take a quick look and let me know if you see anything missing. If not, I'm giving up on this mod.

Thanks


Quote Reply
Re: Top 10 on home page by number of visits In reply to
You need to delete the last right bracket } after return $output;.

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I still get this error:

Can't return outside a subroutine at D:\216.247.220.101\cgi-bin\links\topsites.cgi line 45.

I've tried everything and it's still not working. urgh!


Quote Reply
Re: Top 10 on home page by number of visits In reply to
Well...here are some other suggestions...

1) Since you are on a Windows server, have you tried the similar SSI calls you are using for your other SSI programs.

2) The other problem could be your database delimiter. What is your database delimiter (as defined in the $db_delim variable in the links.def file)???

If it is not |, then you need to change the following codes:

Code:

@data=split (/\|/);


to the following codes:

Code:

@data=split (/$db_delim/);


Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Thanks for all your help.

Still could not get it working,

Here is one thing you could look at.
It is the FAQ on SSI for my server.

http://www.hypermart.net/templater.gsp?id=/development/serverscript/ssifaq

Not sure it this help.

If not I will try talking to the Support people at the compay.

Thanks Again

John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
sorry Just thought of something
You may not be able to access it.

Here is the infomation.
__***************


This tutorial is for the beginner and does not contain detailed information for troubleshooting any SSI problems or scripting errors. If you are having troubles implementing SSI into your HTML documents, please submit your question to our CGI newsgroup. This is an excellent resource for finding similar problems and getting the help you need efficiently and quickly.

Server-side includes at HyperMart is parsed from any HTML document. There is no need to designate with the extension ".shtml", as our servers are scripted to process every document to have an SSI in it or not. You can get more documentation as to what other SSI attributes you can use from NCSA under "SSI Format" (NOTE: all attributes 'must' be in lower-case.) The simplest example of server-parsed HTML is to have a file "foo.html" containing this text:

Line one< P >
!--#exec cmd="/cgi-bin/mycgi.cgi" --
Line three< P >

And then have a file mycgi.cgi that contains, on Unix:

#!/bin/sh
echo "Line two"

Or, on Windows NT, use mycgi.bat as the filename (and make sure you use this filename in your foo.shtml file instead):

@echo off
echo Line two

And when you access foo.html, it will output:

Line one
Line two
Line three

If your include directive is !--#exec cmd="..."--, then the output of the command you specify will be spliced directly into the page output. If your include directive is !--#exec cgi="..." --, then the cgi program you run must output a standard CGI header (Content-type: and whatever other header lines you want, followed by a blank line, then the

Do not put any spaces before the # character in your include directives; if you have <!-- #exec instead of <!--#exec, the line will be ignored.

Server-side includes in "custom trailers" will not work, since custom trailers are appended to the output of your Web pages after all other processing has been done on them. Any server-side includes that you put into your custom trailers will be sent directly to the browser without being parsed.

Our system cannot parse SSI inside of SSI. So if you are trying that, it will not work.

Thanks again..


John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
In Reply To:
Not sure it this help.
Who is trying to help whom???

I am trying to help you...it is not my responsibility to troubleshoot your scripts for you....just to provide helpful suggestions, which I have already done. Wink

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Thanks for the mumble jumble stuff...I really don't know what to tell you...the codes I've provided are strictly SSI and are not executed within SSI.

And it seems that you are not using the correct SSI call in your SSI enabled web page...

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I am using ssi to insert my ads on the same page that I can't get this mod to work. Also, my delimiter is | as defined in links.def.

I'm clueless and unless you can think of anything else, I'm dropping this one since I've already waisted too much time on it.

Thanks for your help.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
The only other suggestion I have is to use the regular TOP TEN Mod....What you could possible do is create a separate .html file from the original codes provided for the Top Ten on home page, then use the SSI to include the .html file...a bit more involved, but it may work.

In Reply To:
I'm clueless and unless you can think of anything else, I'm dropping this one since I've already waisted too much time on it.
Is this is a threat??? Because you have stated this twice now...What do you want me to do???? I have tried to help you and it seems that you are unappreciative of my attempts to assist you...All I can say is best of luck with Links and your future endevours. And if these statements are intended to be a threat...then they are not the most effective method in getting assistance from other Links users.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
I'm sorry my reply seemed a little insulting. I certainly didn't mean anything by it and my sarcasm didn't come across very well. I SINCERELY appreciate all of your, and everyone else in this forum's, help since I would be worthless without it. My frustration of not getting the mod to work made my reply sound like I was complaining about your help which I certainly am not. Sorry again and I'll try to cut out the sarcasm and frustration so I don't give the wrong impression.

I appreciate your help.


Quote Reply
Re: Top 10 on home page by number of visits In reply to
You're welcome...and no offense taken...I was just confused about your intentions in the statement I highlighted before.

Smile

Regards,

Eliot Lee
Quote Reply
I am getting the same error In reply to
I have getting the same error.

Not sure what the problem is.


John

Quote Reply
Work with site_html.pl In reply to
Will this same code work with site_html.pl.

Or are there some changes needed.

All references talk about the site_html_templates.pl.

If anyone knows, it would be appreciated.

Thank you
John

Quote Reply
Re: Work with site_html.pl In reply to
In Reply To:
Will this same code work with site_html.pl.
Yes...it will...Simply use the following codes in the sub site_html_home routine where you want to print the Top Ten....

Code:

~;
&top_ten;
output .= qq~


Regards,


Eliot Lee
Quote Reply
Re: Work with site_html.pl In reply to
Thanks, but getting an error
*******
Error including libraries: Can't modify constant item in concatenation at /data1/hypermart.net/moneysearch/cgi-bin/admin/site_html.pl line 228, near "~;"
(Might be a runaway multi-line ~~ string starting on line 188)

Make sure they exist, permissions are set properly, and paths are set correctly.
*******

I put in my site_html.pl

##########################################################
## Top 10 sites ##
##########################################################

sub top_ten {
#-------------------------------------------
# Insert Top Ten Sites
open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");
LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
\n";
}
$count++;
}
return $output;
}



And for the code for the output. I put on my home page, in the site_html.pl

~;
&top_ten;
output .= qq~


Any idea's on why it may not be working.

Thanks for all your help.

John Schultz
www.incomemax.com

Quote Reply
Re: Work with site_html.pl In reply to
The error message indicates that the PROBLEM is NOT in the sub top_ten routine, but in the sub site_html_home routine.

Please post the sub site_html_home routine.

Regards,

Eliot Lee
Quote Reply
Re: Work with site_html.pl In reply to
Here is my sub site_html_home

http://www.incomemax.com/links/site_html_home.txt

Thanks
Again

John

Quote Reply
Re: Work with site_html.pl In reply to
Okay...I gave you slightly bad codes...

Change the codes I gave you to the following:

Code:

~;
&top_ten;
$output = qq~


Regards,


Eliot Lee
Quote Reply
Re: Work with site_html.pl In reply to
Almost there, the errors are gone.

But now, it does not print out the top ten, and all the code above it is gone.

here is a sample

http://www.incomemax.com/links/index.txt

Thanks John

Quote Reply
Re: Top 10 on home page by number of visits In reply to
hello,

I tested the modifications of ELIOT but nothing is displayed. I do not have any error message...

Of what that can it come well?

Thank you,

Laurent


Quote Reply
Re: Work with site_html.pl In reply to
Try the following THEN...

Create a "global" variable for the top_ten sub, like the following:

$top_ten = &top_ten;

AFTER the following codes:

Code:

$date = &get_date;
$time = &get_time;


Then replace the codes I have given you so far with the following codes where you want the TOP TEN to appear in your sub site_html_home:

Code:

$top_ten


Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Stop SHOUTING my name!!

And I have already responded to your duplicate postings!

Regards,

Eliot Lee
Quote Reply
Re: Work with site_html.pl In reply to
Thanks Again for your help.

It finally works.



Thanks for all your help..

John Schultz

Quote Reply
Re: Work with site_html.pl In reply to
You're welcome....

In Reply To:
It finally works.
NOT....my problem...if you want to fix problems quickly, then I would suggest the following:

1) Buy a Perl book, so that you can learn the basic codes that will assist you in customizing your .cgi and .pl scripts.

2) Take some Perl tutorials online (http://www.cgi101.com).

3) Take a Perl programming course.

Wink

Regards,



Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Can you please give me some more info on how to create a seperate .html file with the top ten so I can use include page to put it on a seperate page. I use include page all the time but I'm not sure how to create the new .html file in links. I created a template with just the top ten global on it and added some code to site_html_templates.pl to try to include the new template in the build process but it doesn't work and I'm stuck. I made my best effort to come up with something on my own but I have no idea how close I am. I'd appreciate any help you can give me.

Thanks much.

Quote Reply
Re: Top 10 on home page by number of visits In reply to
There is a FAQ for creating new .html template files in the Resource Center...Do you know where the Resource Center is located? Have you browsed or searched it? You SHOULD!

Anyway...here is the FAQ:

http://www.anthrotech.com/...inks/faqs/templates/

By using this FAQ, you will be able to use GLOBAL variables in the new template file you create and build via the nph-build.cgi file.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Top 10 on home page by number of visits In reply to
Okay tried this mod and everything is pretty happy except I get a full repeat of all the top 10's
ie: 1-10 in a table
and 1-10 in a table same links

my code:
sub top_ten {
#-------------------------------------------
# Insert Top Ten Sites

open (NAME,"<$db_file_name") or &cgierr("error in numlinks. unable to open database:$db_links_name.\nReason: $!");

LINE: while(<NAME> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$tophits{$data[0]} = $data[8];
$name{$data[0]} = $data[1];
$url{$data[0]} = $data[2];
$descrip{$data[0]} = $data[5];
}
close (NAME);
my $count=1;
foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {
if ($count <= 10) {
# $output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
$descrip{$field}
\n";

$output .= qq|
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#FF0000">
<tr>
<td align="center" valign="middle" width="">$count.</td>
<td valign="middle" width="" height="25" bgcolor="#99CCFF" align="center"><a href=\"$url{$field}\">$name{$field}</a></td>
<td align="center" valign="middle" width="">$descrip{$field}</td>
</tr>
</table>
\n|;

}
$count++;
}
return $output;
}

also I have a small problem the descript instead of "spaces" gives me ''
ie:
dfsadfs``4654546a``asdfdsfs
this is gibberish cause it's a test link

thanks for your help

Quote Reply
Re: Top 10 on home page by number of visits In reply to
okay figured out the repeated table problem:

the comment line was screwing me over.
# $output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>$descrip{$field}\n";

now how do you deal with the spaces ??? anybody have a suggestion?

Quote Reply
Re: [jcrow] Top 10 on home page by number of visits In reply to
Hi!

wondered what code should i put to have links listed like;

1. Site
Hits: 1234
2. Site2
Hits: 1265
3. Site3
Hits: 3435

thanx in advance

Gregor
Quote Reply
Re: [Chewbaca] Top 10 on home page by number of visits In reply to
Hi Elliot!

I'm getting error on your mod. Is there anyway you can send me a copy of the mod in original text file or .cgi/.pl file?. Because I copied exactly the way your mod appeared in this forum but when I installed it. it show errors. I've checked the path, permission they all right. I can't figure out how to get it work. I need your help.


huy

If you can send it to
hxt99@yahoo.com.au
Quote Reply
Re: [huy] Top 10 on home page by number of visits In reply to
What errors???

I ain't a mind reader...please post the exact errors you received and may be we can help you. Ambigous statements like "I got errors" only delays assistance and raises confusion.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Heckler] Top 10 on home page by number of visits In reply to
HI. I tried inserting this code into my

site_html_tepmplates.pl

here's the error i got

Error including libraries: Missing right bracket at /t4cmini/public_html/cgi-bin/search/admin/site_html_templates.pl line 407, at end of line
syntax error at /t4cmini/public_html/cgi-bin/search/admin/site_html_templates.pl line 407, at EOF

Make sure they exist, permissions are set properly, and paths are set correctly.


I'll post my code.. could you tell me what i did wrong please? thanks!










# -------------
# Links
# -------------
# Links Manager
#
# File: site_html.pl
# Description: This library contains all the HTML that will be generated in
# the finished directory.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.01
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================

# ----------------------------------------------------------------------
# The HTML in this file and the style sheet (links.css) have been authored
# by Chris Croome of webarchitects.
#
# Email: chris@atomism.demon.co.uk
# Web: http://www.webarchitects.co.uk/
# ----------------------------------------------------------------------

# You can put variables here that you would like to use in any
# of your templates.

%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
topsites => &top_ten,
css => $build_css_url,
banner => ''
);


sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}

sub site_html_home {
# --------------------------------------------------------# This routine will build a home page. It is not meant to have any # links on it, only subcategories.my (@data,%tophits,%name,%url);open (NAME,"<$db_file_name"); LINE: while(<NAME> ){ next LINE if (/^#/); next LINE if (/^\s*$/); @data=split (/\|/); $tophits{$data[0]} = $data[8]; $name{$data[0]} = $data[1]; $url{$data[0]} = $data[2];}close (NAME);my $count=1;foreach $field (sort { $tophits{$b} <=> $tophits{$a} } keys %tophits) {if ($count <= 10) {$topsites_output .= "$count. <a href=\"$url{$field}\">$name{$field}</a><br>\n";}$count++;} return &load_template ('home.html', { topsites_output => $topsites_output, category => $category, grand_total => $grand_total, %globals });}

sub site_html_new {
# --------------------------------------------------------
# This routine will build a what's new page.

return &load_template ('new.html', {
total => $total,
grand_total => $grand_total,
link_results => $link_results,
title_linked => $title_linked,
%globals
} );
}

sub site_html_cool {
# --------------------------------------------------------
# This routine will build a what's new page.

return &load_template ('cool.html', {
total => $total,
grand_total => $grand_total,
percent => $percent,
link_results => $link_results,
title_linked => $title_linked,
%globals
} );
}

sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#
my %rec = @_;
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );
}

sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.

return &load_template ( 'category.html', {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}

sub site_html_ratings {
# --------------------------------------------------------
# This routine determines how the top rated page will look like.

return &load_template ( 'rate_top.html', {
top_rated => $top_rated,
top_votes => $top_votes,
%globals
});
}

########################################################################################
# THE FOLLOWING ARE CGI GENERATED PAGES AND THE TEMPLATE MUST BE PRINTED, NOT RETURNED!#
########################################################################################

sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));

print &load_template ('add.html', {
Category => $category,
%globals
});
}

sub site_html_add_success {
# --------------------------------------------------------
# This routine determines how the add success page will look like.

&html_print_headers;

print &load_template ('add_success.html', {
%in,
%globals
});
}

sub site_html_add_failure {
# --------------------------------------------------------
# This routine determines how the add failure page will look like.

my ($errormsg) = shift;
$in{'Category'} ?
($in{'Category'} = qq~<input type=hidden name="Category" value="$in{'Category'}">$in{'Category'}~) :
($in{'Category'} = &build_select_field ("Category"));

&html_print_headers;
print &load_template ('add_error.html', {
error => $errormsg,
%in,
%globals
});

}

sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.

my $category = &build_select_field ("Category", "$in{'Category'}");

&html_print_headers;
print &load_template ('modify.html', {
Category => $category,
%globals
});
}

sub site_html_modify_success {
# --------------------------------------------------------
# This routine determines how the modify success page will look like.

&html_print_headers;
print &load_template ('modify_success.html', {
%in,
%globals
});
}

sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.

my $errormsg = shift;
$in{'Category'} = &build_select_field ("Category", $in{'Category'});

&html_print_headers;
print &load_template ('modify_error.html', {
error => $errormsg,
%in,
%globals
});
}

sub site_html_search_results {
# --------------------------------------------------------
# This routine displays the search results.
#
my $term = &urlencode ($in{'query'});
&html_print_headers;
print &load_template ('search_results.html', {
term => $term,
link_results => $link_results,
category_results => $category_results,
next => $next,
cat_hits => $cat_hits,
link_hits => $link_hits,
%in,
%globals
});
}

sub site_html_search_failure {
# --------------------------------------------------------
# This routine displays a failed search page with error in $error.
#
my $error = shift;
my $term = &urlencode ($in{'query'});
&html_print_headers;

print &load_template ('search_error.html', {
term => $term,
error => $error,
%in,
%globals
});
}

sub site_html_search_form {
# --------------------------------------------------------
# This routine displays the search form.

&html_print_headers;
print &load_template ('search.html', {
term => $term,
error => $error,
%in,
%globals
});
}

sub site_html_mailing {
# --------------------------------------------------------
# This routine displays your mailing list subscribe/unsubscribe form.
#
my $action = shift;
my $message;
($action eq 'subscribe') and ($message = qq~You've been successfully subscribed to the mailing list!~);
($action eq 'unsubscribe') and ($message = qq~You've been successfully removed from the mailing list!~);

&html_print_headers;
print &load_template ('email.html', {
message => $message,
%in,
%globals
});
}

sub site_html_mailing_error {
# --------------------------------------------------------
# This routine is displayed if there was a problem subscribing.
#
my $error = shift;

&html_print_headers();
print &load_template ('email_error.html', {
error => $error,
%in,
%globals
});
}

sub site_html_rate_form {
# --------------------------------------------------------
# This routine determines how the rate form page will look like.
#
my %rec = @_;

&html_print_headers;
print &load_template ('rate.html', {
%rec,
%globals
});
}

sub site_html_rate_success {
# --------------------------------------------------------
# This routine determines how the rate success page will look like.

&html_print_headers;
print &load_template ('rate_success.html', {
%in,
%globals
});
}

sub site_html_rate_failure {
# --------------------------------------------------------
# This routine determines how the rate failure page will look like.

my ($errormsg) = shift;

&html_print_headers;
print &load_template ('rate_error.html', {
error => $errormsg,
%in,
%globals
});

}

########################################################################################
# THE FOLLOWING DETERMINES YOUR CATEGORY LISTING, IT'S NOT TEMPLATE BASED (YET)! #
########################################################################################

sub site_html_print_cat {
# --------------------------------------------------------
# This routine determines how the list of categories will look.
# We now use a table to split the category name up into two columns.
# For each category you can use the following variables:
#
# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# $category_descriptions{$subcat}: The category description (if any).
# $numlinks : The number of links inside that category (and subcategories).
# $mod : The newest link inside of that category.
#

my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($half) = int (($#subcat+2) / 2);

# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($i == $half) {
$output .= qq|</td><td class="catlist" valign="top">\n|;
}
$i++;

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}

# Don't forget to end the unordered list..
$output .= "</td></tr></table></div>\n";
return $output;
}

1;
Quote Reply
Re: [CEGlobe] Top 10 on home page by number of visits In reply to
In Reply To:


return &load_template ('home.html', {
topsites_output => $topsites_output,
category => $category,
grand_total => $grand_total,
%globals
});
}[/code]

Hi, just wondering what happened to "hits => $hits," and what is it for?

Thanks,

Will
Quote Reply
Re: [CEGlobe] Top 10 on home page by number of visits In reply to
 
I get the error:


Unkown Tag: topsites_output

any ideas?

Thanks,

Will
Quote Reply
Re: [Heckler] Top 10 on home page by number of visits In reply to
In Reply To:
$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
\n";

I tried chaging to

$output .= "$count. <a href=\"$url{$field}\">$name{$field}</a>
\n". $tophits;

I am trying to show the number of hits... but it doesn't work. Anyone know why?

Thanks,

Will


Quote Reply
Re: [Heckler] Top 10 on home page by number of visits In reply to
Sorry for digging this archive back up, but I have just installed this mod and it works well. At the top of this thread it was asked if the title can be limited to lets say 15 characters. A solution is provided by the use of nested tables.

Its an option but can anyone elese provide another solution, I ask this because some of my titles can be up to 20 - 30 characters in length and its looking messy.

Thanx

Stu
Quote Reply
Re: [stu2000] Top 10 on home page by number of visits In reply to
Search this forum for substr or length, you can reduce the number of characters by using perl.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [stu2000] Top 10 on home page by number of visits In reply to
$variable = substr($variable, 0, 15);

Last edited by:

Paul: Mar 25, 2002, 1:50 AM
Quote Reply
Re: [Paul] Top 10 on home page by number of visits In reply to
thanx Paul Cool