Code:
sub { my $user = shift;
my $post = $DB->table('User')->select( { user_id => $user }, 'user_posts' )->fetchrow;
my $karma = $DB->table('Post')->select( { user_id_fk => $user }, 'SUM(post_karma)' )->fetchrow;
return { user_post_title => $post + $karma };
}
I think you can add something like that as a global then add the tag in include_post_display.html - the tag would be:
<%calculate_karma($user_id_fk)%>
And then you can put <%user_post_title%> wherever you want. You can turn it into a name rather than a number with something like:
Code:
<%if user_post_title > '-50' and user_post_title < '1'%> Naughy Boy
<%elsif user_post_title > '0' and user_post_title < '51'%>
Average Person
<%elsif user_post_title > '50' and user_post_title < '101'%>
Mr Nice Guy
<%elsif user_post_title > '100'>
Karma God
<%endif%>