Yes, it would be possible by using a global; the following should do the trick:
my ($post, $root, $current_user) = @_;
$root ||= $post;
return { user_contributed => 0 } unless $current_user;
my $contributed = $DB->table('Post')->count({ post_root_id => $root, user_id_fk => $current_user })
|| $DB->table('Post')->count({ post_id => $root, user_id_fk => $current_user });
return { user_contributed => $contributed ? 1 : 0 };
}
Then, in your template, simply do something like:
<%if user_contributed%>... HTML here to display the icon ...<%endif%>
Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Code:
sub { my ($post, $root, $current_user) = @_;
$root ||= $post;
return { user_contributed => 0 } unless $current_user;
my $contributed = $DB->table('Post')->count({ post_root_id => $root, user_id_fk => $current_user })
|| $DB->table('Post')->count({ post_id => $root, user_id_fk => $current_user });
return { user_contributed => $contributed ? 1 : 0 };
}
Then, in your template, simply do something like:
Code:
<%global_name($post_id, $post_root_id, $current_user_id)%> <%if user_contributed%>... HTML here to display the icon ...<%endif%>
Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com