<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,102)">Hi folks<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,102)">I'm relatively new to this, so sorry if this is a silly question - and sorry if it goes to the wrong place (I'm still not sure it's not a Template Toolkit issue):<br><br>I am developing a Catalyst application using DBIx::Class and Template
Toolkit; in the particular part I'm having issues with, I have a
resultset obtained using by calling the following function in my
ResultSet schema:<br><br><span style="font-family:monospace,monospace"> sub divisions_and_teams_in_season {<br> my ( $self, $season, $grid ) = @_;<br><br> return $self->search({<br> "division_seasons.season" => $season->id,<br> "division_seasons.fixtures_grid" => $grid->id,<br> }, {<br> prefetch => [<br> "division_seasons",<br> {<br> "team_seasons" => {<br> "team" => [{<br> "club" => "venue"<br> },<br> "home_night"<br> ]<br> }<br> }<br> ],<br> order_by => {<br> -asc => [ qw( division_seasons.rank team_seasons.grid_position club.short_name <a href="http://team.name">team.name</a> ) ]<br> }<br> });<br> }</span><br><br><br>This returns the data as I would expect and I'm able to do the following
in my Controller code to get back my resultset and iterate through the
team_seasons:<br><br><span style="font-family:monospace,monospace"> my $divisions = [ $c->model("DB::Division")->divisions_and_teams_in_season($current_season, $c->stash->{grid}) ];<br><br> foreach my $division ( @{ $divisions } ) {<br> $c->log->debug( $division->team_seasons->grid_positions_filled ); # This works I guess because $division->team_seasons is a resultset object <br> }</span><br><br>However, in my template (having stashed <code>$divisions</code>), I'm
unable to access the grid_positions_filled object because
division.team_seaons gives me an arrayref of team resultsets in that
division:<br><br><span style="font-family:monospace,monospace"> [%<br> # Loop through our divisions<br> FOREACH division IN divisions;<br> CALL c.log.debug(division.team_seasons); # The output of this is something like: ARRAY(0x6f8318c)<br> END;<br> -%]</span><br><br><p>The output I get for the same debug log in my controller is more like a list of resultset objects:</p><p><br></p><span style="font-family:monospace,monospace"> TopTable::Model::DB::TeamSeason=HASH(0x6eea94c)<br> TopTable::Model::DB::TeamSeason=HASH(0x6f01834)<br> TopTable::Model::DB::TeamSeason=HASH(0x6ef5284)<br> TopTable::Model::DB::TeamSeason=HASH(0x6efec9c)<br> TopTable::Model::DB::TeamSeason=HASH(0x6ef4dc4)<br> TopTable::Model::DB::TeamSeason=HASH(0x6faf0ac)<br> TopTable::Model::DB::TeamSeason=HASH(0x6eefa04)</span><br><br><p>Hope all this makes sense! Does anyone know how I can get the
behaviour from the controller into the template so that I can access
methods on the team_season ResultSet?</p>
<p>Thank you very much in advance.</p><p><br></p><p>Chris<br></p><br></div></div>