Gossamer Forum
Home : Products : Gossamer Links : Discussions :

<<< most popular in detailed page >>>

Quote Reply
<<< most popular in detailed page >>>
HiWink

I have installed succesfully the global that displays the 5 most popular links for each main category

sub {
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY hits DESC', 'LIMIT 5');
my $sth = $db->select ( { 'CatLinks.CategoryID' => $id}, ['Links.ID', 'Links.Title', , 'Links.URL'], { isValidated => 'Yes'} ); my $popularcategory; while (my ($id,$name,$url) = $sth->fetchrow_array) { $popularcategory .= "<a href='$url'>$name</a><br>";
}
return $popularcategory;
}


and putting <%popular (ID)%> in my category template

but how to display those popular in a detailed page???

ThanksWink

FMP
Quote Reply
Re: [fmp] <<< most popular in detailed page >>> In reply to
Hi,

If you replace:

my $id = shift;

with:

Code:
my $id = shift;
if (ref $id) {
my $link_id = $id->{ID}:
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories ($link->{ID})};
$id = $cat_id;
}


and just use: <%popular%>. Getting a bit hackish, but it should work. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] <<< most popular in detailed page >>> In reply to
Hi AlexWink...thanks for your answer

I am sure I am so close....

I have the following error message

GT::Config (15022): Unable to compile 'last_links' in file '/blah/blah/cgi-bin/blah/admin/templates/default/globals.txt': syntax error at (eval 18) line 3, near "}:"
syntax error at (eval 18) line 6, near ";
}"
at '/blah/blah/cgi-bin/actualite_en_finance/admin/GT/Template.pm line 461.


I though it was because of this portion of code :
my $link_id = $id->{ID}:

that I replaced by
my $link_id = $id->{ID};

But I have another message... :
Unable to compile 'popular' so it wasn't the prob


Thanks for your help (or for the help of anybodyelse :) )



FMP Wink