I'm having a bit of a go of getting all the bits in place to do paging. The error I'm hung on is:<br><span style="font-family: monospace;">"</span><code class="error">Can't call method "pager" on unblessed reference</code>"<br><br>Here's the story:<br>My display template first asks the user to select a gallery to display, then displays a list of thumbnail images. My controller 1) runs query to get the galleries for the display template; 2) writes an HTML::Widget form; 3) checks to see if there is a $selected_gallery; 4) If there is, query db for photos. <br><br>Line below marked # ??? gives the error; removing that line, I can select a gallery and display the images -- but without paging.<br><br># - - - - - - - - - - - - - - - - - - <br>package Catapult::Controller::Photo::Gallery;<br># - - - - - - - - - - - - - - - - - - <br>use Data::Page;<br><br>################<br>sub display : Local {<br> my ($self, $c) = @_;<br><br> $c->log->debug("Get Galleries
");<br> my @galObjs = $c->model("CatapultDB::Galleries")->all();<br> my @gals = map {$_->id => $_->name }<br> sort {$a->name cmp $b->name} @galObjs;<br> my $selected_gallery = $c->request->params->{select_gal};<br><br><snip><br>make the html::widget form here<br><snip><br><br>if ( $selected_gallery ) {<br><br> my $pager = Data::Page->new(); <br><br> $c->log->debug("Selected Gallery: $selected_gallery");<br> $c->stash->{photos} = [$c->model('CatapultDB::Photos')->search(<br> {<br> 'gallery.id' => $selected_gallery<br> },<br> {<br> join => [qw/ gallery
/],<br> prefetch => [qw/ gallery /],<br> rows => 1,<br> }<br> )];<br><br>$c->stash->{pager} => $c->stash->{photos}->pager(); # ???<br><br> }<br># - - - - - - - - - - - - - - - - - - <br>display.tt<br># - - - - - - - - - - - - - - - - - - <br>[% IF photos.size %]<br><br><h3>Gallery: [% photos.gallery.name %]</h3><br><br><div id="thumbnails"><br><ul><br>[% FOREACH photo IN photos -%]<br> <li><br> <a href="[% c.stash.action %]/[% photo.gallery.id %]/[% photo.id %]" <br> title="[% photo.name %]"><br> <img src="/static/galleries/[% photo.gallery.directory %]/_t/t_[% photo.filename %]" <br> alt="[% photo.gallery.name %][% photo.gallery.name %]"></a><br> </li><br>[% END
-%]<br></ul><br></div><br><br> [% IF pager.previous_page %]<br> <a href="[% c.request.uri_with( page => pager.previous_page ) %]">Previous Page</a><br> [% END %]<br> [% IF pager.next_page %]<br> <a href="[% c.request.uri_with( page => pager.next_page ) %]">Next Page</a><br> [% END %]<br><br>[% ELSE %]<br> <h3>There are currently no photos in this gallery.</h3><br>[% END %]<br># - - - - - - - - - - - - - - - - - - <br><br>Help is much appreciated.<br><br>/dennis<br><br>