Hi,
I want to use a DBIx::Class resultset object in a TT template, but I am
missing something and I can't get the correct value.
I have a row object $user and I want to get the number of comments sent by
that user from a related table named user_comment, using the relation
user_comments. The perl code for doing this is:
my $number_of_comments = $user->user_comments->count;
In the TT template I tried to use:
[% number_of_comments = user.user_comments.count %]
But it doesn't print anything when I print the var number_of_comments.
In this particular case I could get the entire array of comments and apply
the .size vmethod, but it wouldn't work in all cases. For example, I would
also like to get the votes for the current user, and I need to use a sum()
method like:
my $number_of_votes = $user->user_votes->get_column('vote')->sum;
I have tried in TT:
[% number_of_votes = user.user_votes.get_column('vote').sum %]
But it doesn't work either.
Please tell me what I am missing, because I think it should be possible to
use these method calls in TT templates.
Thank you.
Octavian
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates