Gossamer Forum
Quote Reply
Hits Site on HomePage
Hi, I want show on my HomePage a list site by Hits
Like this listing

65 site1
34 site2
22 site3
15 site4
10 site5
How I can do it?
Thanks in advance
Bye From Italy
Fabio

Fabio
Quote Reply
Re: Hits Site on HomePage In reply to
Someone can Help Me?
Thanks
Fabio

Fabio
Quote Reply
Re: Hits Site on HomePage In reply to
Hi,

You should use globals, add something like:

top5 =>

Code:
sub {
my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', 'LIMIT 5');
my $sth = $table->select;
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
and then just put <%top5%> somewhere on your home.html page.

Cheers,

Alex

--
Gossamer Threads Inc.

Last edited by:

Inertia: Nov 4, 2008, 3:48 PM
Quote Reply
Re: Hits Site on HomePage In reply to
Thanks Alex but I need to short description for <%Title%> tag, I've used this code but it repeat two times title:

sub { my $tags = shift; my $desc = $tags->{Title} or return ""; length $desc < 10 and return $desc; my $short = substr ($desc, 0, 300); $short =~ s/\s\S+?$//; $short .= " ......"; return $short;}

How I can Do it?
Thanks in advance
Bye From Italy
Fabio

Fabio
Quote Reply
Re: Hits Site on HomePage In reply to
Hi,

If you change that too:

Code:
sub {
my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', 'LIMIT 5');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top5_loop => \@output };
}
You can then make your template:

Code:
<%top5%>
<%loop top5_loop%>
<%Title%>: <%Hits%>

<%endloop%>
and format it however you want.

Cheers,

Alex

--
Gossamer Threads Inc.

Last edited by:

Alex: Dec 13, 2001, 7:29 PM
Quote Reply
Re: Hits Site on HomePage In reply to
Thanks but I've this error:

Building Home Page ...
A fatal error has occured:Can't use string ("") as a subroutine ref while "strict refs" in use at /home/mysite/cgi-bin/admin/Links.pm line 287.
Please enable debugging in setup for more details.
Thanks again
Bye From Italy
Fabio

Fabio
Quote Reply
Re: Hits Site on HomePage In reply to
ummm just guessing you copied the codes from Alex's comments and forgot ";" after "my @output" . that's it Wink.
hope that will help...
windsor

Quote Reply
Re: [doublemint] Hits Site on HomePage In reply to
How do I make the top 5 list into links?

Thanks

CCUnet
my Christian web
Quote Reply
Re: [ccunet] Hits Site on HomePage In reply to
1 - And how will I be able to display the category name infront of the displayed link? and also,
2 - how to split the list into two columns to be consistent with the category listing on the home page.
Thanks
Mark
Quote Reply
Re: [Mark2] Hits Site on HomePage In reply to
What code and tag works with Gossamer Links 3.3.0?
http://www.hopeforyou.com

Quote Reply
Re: [HopeForYou] Hits Site on HomePage In reply to
This will work fine in GLinks 3.3:

http://www.gossamer-threads.com/...age_P153582/#p153582

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!