Cybris has asked for the wisdom of the Perl Monks concerning the following question:
Oops, it seems I accidentally overwrote my original question, instead of replying to it. Sorry. Anyway, the question was how to determine the number of rows in a DBIx::Class::ResultSet object from within TT2.
I have found the solution myself:
[%# set the variable objects to an array of 0 or more objects, taken f +rom user.objects, which is a DBIx::Class::ResultSet %] [% IF user.objects %] [% IF user.objects.0 %] [% SET objects = user.objects %] [% ELSE %] [% SET objects = [ user.objects ] %] [% END %] [% ELSE %] [% SET objects = [] %] [% END %] Number of objects: [% objects.size %]
Unfortunately, it is not possible to write a macro for this, because TT macros can't return results...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBIx::Class and Template toolkit context problem
by LTjake (Prior) on Jan 05, 2010 at 15:42 UTC | |
by Cybris (Sexton) on Jan 05, 2010 at 15:51 UTC |