Hello Andy,
I've different globals (please don't wonder, this is very mixed stuff, because I did this globals and the other things at total different times and with total different tips ... It worked for me well since years so I didn't have to change it ...):
1. a Top-10-List: global:
Code:
sub {
my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top5_loop => \@output };
}
template:
Code:
<%top5%>
<%loop top5_loop%>
<div class="abstand">
<%row_num%>
. <a class="noline" href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>"><%Title%></a>
2. then a list with newest links. global:
Code:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 10');
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('new_links', $link);
}
return $output;
}
template:
and (new_links.html):
Code:
<li class="linkliste">
<a class="noline" href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>"><%Title%></a>
<br class="half">
<span class="greytext">-> Seit: <%GT::Date::date_transform($Add_Date, '%yyyy%-%mm%-%dd%', '%dd%.%mm%.%yyyy%')%></span></li>
3. a list with featured links:
template:
Code:
<%list_isbest%>
<%loop All_Loop%>
<li class="linkliste"><a class="noline" href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>">
<%Title%>
<span class="greytext"> (<%Hits%>)</span></a></li>
<%endloop%>
global:
Code:
sub {
# Displays 10 premium-links.
my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Add_Date DESC','LIMIT 10');
my $sth = $table->select({ isBest => 'Ja' });
my @output;
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
push (@output, $link);
}
return { All_Loop => \@output };
}
4. and another list with the newest links:
global:
Code:
sub {
#Top 10 sites by hits.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links');
$db->select_options ('ORDER BY Add_Date DESC', 'LIMIT 3');
my $sth = $db->select ( { isValidated => 'Yes'} );
my $premium;
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link3', $link);
}
return $output;
}
template:
and (link3.html)
Code:
<br>
<div class="menuline"><a class="noline" href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>"><%Title%></a><span class="greytext"> seit <%GT::Date::date_transform($Add_Date, '%yyyy%-%mm%-%dd%', '%dd%.%mm%.%yyyy%')%>.</span></div>
<div class= "menutext"><%short_desc%></div>
<br class="half">
I like to change all the "detail_page_cgi"-stuff into detailed url, because I've these oretty URLs but dont't use them enough - I think. I don't want to mix the ways to get the detailed page anymore ...
Kai
___________________________________________
http://www.westalgarve.de http://www.portugalforum.org http://www.portugal-links.de