Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Display top 10 most popular in home.html???

Quote Reply
Display top 10 most popular in home.html???
Hi, I will try to figure out myself, but any suggestion is welcome. I am trying to display a table that displays top 10 most popular links maybe with amount of hits next to it in my home.html.

Kinda like the table in http://www.hotscripts.com/Popular/

What essential tag do I need? Thanks in advance.
Quote Reply
Re: [flybuzz] Display top 10 most popular in home.html??? In reply to
Try this:

You will need:
1/ Global > “top_10
2/ Template > “top_ten.html
3/ Modify > “home.html” template.

Place the following into your “Template Globals” in the Admin area.
NB: Change the “LIMIT 10” in the global to the amount you want to display.

sub {
#Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display (top_ten, $link);
}
return $output;
}


Make up a template top_ten.html which has the following in it:
<table>
<tr>
<td width="100%">
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>" target="_blank">
<%Title%>:</a><br>
<font size="1" color="#FF0000">
<span style="background-color: #E6E6E6">
<font color="#FF0000">with <%Hits%> hits.</font></span></font></td>
</tr>
</table>

This shows the Title and Hits, change to suit.

Then upload that template to your "local" template directory.

Place the following tag in your home.html template.
<%top_10%>

The global will pull the info from the top_ten.html template and display them where you place the <%top_10%> tag.

Regards

minesite
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
Hey, thank you so much for the help. But I found out that I can edit certain things under setup/build options. I found build_sort_order_cool just fill in Hits DESC and that does the job. Now I just need to make a table and display them... appreciate your help. Smile
Quote Reply
Re: [flybuzz] Display top 10 most popular in home.html??? In reply to
Hi Flybuzz



“I am trying to display a table that displays top 10 most popular links maybe with amount of hits next to it in my home.html”

“ I found build_sort_order_cool just fill in Hits DESC and that does the job.”



Just curious, what tag are you using to call the display on the home.html template.

Regards

minesite
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
I am still working on that, I am sure I will need to create a new html just like the link.htm since I don't want rest of the pages display the table the same way I display it on the home page.
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
No, it's harder than I thought. Since all the links results goes to 1 single file links.htm there's no linksresults.htm to edit. Therefore I can't change linkresults or make my own version of linkresults... I tried your code but got an error:

Unable to compile 'top_10': Bareword "top_ten" not allowed while "strict subs" in use at (eval 18) line 9.
any ideas? I don't suppose you tested the code?
Quote Reply
Re: [flybuzz] Display top 10 most popular in home.html??? In reply to
Sorry about that, top_ten should be
'top_ten' not top_ten , note the '.



I don't suppose you tested the code?


It has been tested and I had been using it on mysite for quite awhile, error was when changing to suit your application.

NB: This is not my global, It's been posted on the Forum many times before and it may even be listed in the resources section.

I'm a copy and paste guy with no idea re perl, globals etc.

Regards

minesite
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
Got an idea but I don't know the syntax of doing it... how do I do:

if cool{
do cool part
}

if notcool{
do the regular part
}

It can happen in links.html if I know how to do the syntax:

<%if isPopular%>
....
<%endif%>

<%if not isPopular%>...???? How can I do it?
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
well, I got yours to print... I will work on that instead... Thanks.
Quote Reply
Re: [minesite] Display top 10 most popular in home.html??? In reply to
Hi Minesite-

Can we go one step further?

I have the global for last # and popular, etc. but I am using both 'links' and 'if not link then show detail page'. So what happens now is if the link isn't a link I get an error.

What would be the code to use for this?

Thanks!