Andy wrote:
Mmm.. not sure to be honest. Its a lot of work putting something like this together (more in terms of having to document it, so people know how to use it :P)
I can imagine the time you spent on this global plugin.
In fact the explanations are really good.
There are so many globals in glinks. It's a shame that there are no globals in gcommunity
If you have any globals for gcommunity. I'll take them without explanations
Some more of the globals I'm using:
Lastest 5 new links
Code:
sub { my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY ID DESC', 'LIMIT 5');
my $sth = $table->select( { isNew => 'Yes', isValidated => 'Yes' });
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { Lastlinks5_loop => \@output };
}
Latest Reviews
Code:
sub { my (@links,$sth,$link);
my $search_db = $DB->table('Links','Reviews');
$search_db->select_options ("ORDER BY Review_Date DESC","LIMIT $_[0]");
$sth = $search_db->select ( { Review_Validated => 'Yes' });
while (my $link = $sth->fetchrow_hashref()) {
if (length $link->{Title} > 70) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';}
$link = Links::SiteHTML::tags('link', $link);
push@links, $link;
}
return {Latest_Revs=>\@links};<br>
}
Random Link
Code:
sub { my $tags = shift;
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 3;
my (@output, $sth);
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
if ($cat_id) {
$sth = $link_db->select ( { CategoryID => $cat_id });
}
else {
$sth = $link_db->select;
}
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Random_Loop => \@output }
}
Category Menu everywhere
Code:
sub { my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY priority");
my $sth = $cat_db->select (['Full_Name'], { FatherID => 0 });
my $output;
while ( my $root_cat = $sth->fetchrow_array) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<li><a href="$CFG->{build_root_url}/$url/index.html">$root_cat</a></li>~;
}
return $output;
}
By the way,
I'm using the global "user listings" in a different way than you are describing it in the plugin.
My way is just an overview on a user page:
Code:
<%users_listings%> <h2>Your last 3 Entries</h2>
<%loop user_links%>
<ul style="list-style-type: none;">
<li><small><%row_num%>. <%if Build_Detailed_Page eq "1"%><a href="<%build_root_url%>/Detailed/<%ID%>.html"><%elsif URL ne 'http://' and isValidated eq 'Yes'%><a href="<%URL%>"><%endif%><%Title%></a> (<%Hits%> | <%Rating%>)</small></li>
</ul>
<%endloop%><br/><br/>
<h2>Your Top 10 Entries (Hits)</h2>
<%loop user_links_by_hit%>
<ul style="list-style-type: none;">
<li><small><%row_num%>. <a href="<%build_root_url%>/Detailed/<%ID%>.html"><%Title%> </a>(<%Hits%> | <%Rating%>)</small></li>
</ul>
<%endloop%><br/><br/>
<h2>Your Top 10 Entries (Rate)</h2>
<%loop user_links_by_rating%>
<ul style="list-style-type: none;">
<li><small><%row_num%>. <a href="<%build_root_url%>/Detailed/<%ID%>.html"><%Title%> </a>(<%Rating%> | <%Hits%>)</small></li>
</ul>
<%endloop%><br/><br/>
Thanks
Matthias
Matthias
gpaed.de