either use iterators in both controller and template, or use array-
refs in both, but don't try to use both at once with only one variable.
On Jun 19, 2007, at 12:09 PM, John Goulah wrote:
On 6/19/07, Michael Reece <[EMAIL PROTECTED]> wrote:
i believe you are getting an array-ref because you are calling it
in list context via the [ ... ] here.
my $myalums = [ $c->model('MyDB::Alumni')->search({}, { rows =>
20 }) ] ;
try:
my $myalums_iter = $c->model('MyDB::Alumni')->search({},
{ rows => 20 });
while (my $alum = $myalums_iter->next) { ... }
You are correct (and I did explain that as well in my original post
that was happening). So the question is , how can I make the same
call and access the data in both places?
pick one:
my $myalums = $c->stash->{alumni} = [ $c->model('MyDB::Alumni')-
>search({}, { rows => 20 }) ] ;
foreach my $alum (@$myalums) {
print "id: ", $alum->alum_id, "\n";
}
...
[% FOREACH alum IN alumni -%]
id: [% alum.alumni_id %] <br />
[% END -%]
-or-
my $myalums = $c->stash->{alumni} = $c->model('MyDB::Alumni')-
>search({}, { rows => 20 });
while (my $alum = $myalums->next) {
print "id: ", $alum->alum_id, "\n";
}
$myalums->reset; # reset iterator!
...
[%WHILE (alum = alumni.next) %]
id: [% alum.alumni_id %] <br />
[% END -%]
_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/