<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3020" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>Hello,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>Maybe you should try this...&nbsp; You should know what page your user 
wants because they've clicked on a link to display a certain page (or just 
default to the first page if parameter doesn't exist which DBIx::Class will 
do).&nbsp; So your action should have access to what page to display via 
$c-&gt;req-&gt;params('page').&nbsp; Then in the controller you get all of the 
photo objects for that particular page (notice the -&gt;all method at the end of 
the search) and put that in your stash for TT.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>my $page = $c-&gt;req-&gt;params('page') || '';</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>$c-&gt;stash-&gt;{photos} = 
[$c-&gt;model('CatapultDB::Photos')-&gt;search(</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'gallery.id' =&gt; 
$selected_gallery</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; },</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;join&nbsp;&nbsp;&nbsp;&nbsp; =&gt; 
[qw/ gallery /],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prefetch =&gt; [qw/ gallery 
/],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rows&nbsp;&nbsp;&nbsp;&nbsp; =&gt; 
2,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; page&nbsp;&nbsp;&nbsp;&nbsp; =&gt; 
$page,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>)-&gt;all];</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>Then in TT code just like you wrote:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>[% FOREACH photo IN photos -%]<BR>[% photo.gallery.name %]<BR>[% END 
-%]</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>I hope this might help?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2>Leandro</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843065617-30122006><FONT face="Courier New" 
size=2></FONT></SPAN>&nbsp;</DIV><FONT face="Courier New" size=2></FONT><BR>
<BLOCKQUOTE 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT 
  face="Courier New" size=2>
  <HR tabIndex=-1>
  </FONT><FONT face="Courier New"><FONT size=2><B>From:</B> Dennis Daupert 
  [mailto:ddaupert@sbcglobal.net] <BR><B>Sent:</B> Friday, December 29, 2006 
  22:38<BR><B>To:</B> catalyst@lists.rawmode.org<BR><B>Subject:</B> Re: 
  [Catalyst] DBIx::Class/TT Pager Question<BR><BR></FONT></FONT></DIV>
  <DIV><FONT face="Courier New" size=2></FONT></DIV><FONT face="Courier New" 
  size=2>Leandro:<BR>&gt; you don't need to use Data::Page directly <BR><BR>yes, 
  you are quite right, I took out the<BR>explicit call to Data::Page; I set rows 
  =&gt; 2,<BR>and my query gets 2 thumbs. Cool.<BR><BR>&gt;you are setting 
  $c-&gt;stash-&gt;{photos} to an <BR>&gt;array reference when you do 
  <BR>&gt;$c-&gt;stash-&gt;{photos} = [$c-&gt;model( ... ]; <BR>&gt;and then you 
  are later trying to make a <BR>&gt;method call -&gt;pager() on that array 
  reference, <BR>&gt;not an object. <BR><BR>With the square brackets, I get an 
  array ref, <BR>and in my template, I do stuff like:<BR>[% FOREACH photo IN 
  photos -%]<BR>[% photo.gallery.name %]<BR>[% END -%]<BR><BR>When I take the 
  square brackets out of the<BR>query, my template doesn't display 
  anything<BR>anymore. <BR><BR>&gt;See the "Paged Results" section of the 
  <BR>&gt;DBIx::Class::Manual::Cookbook POD on<BR>&gt;CPAN.<BR><BR>which of 
  course I'd been trying to beat <BR>into my forehead. Cookbook says:<BR>"you 
  can return a Data::Page object for the resultset <BR>(suitable for use in e.g. 
  a template) <BR>using the pager method:<BR><BR>return 
  $rs-&gt;pager();"<BR><BR>So I'm trying to call the pager method from 
  the<BR>resultset. But translating from the cookbook<BR>example (which is 
  non-Catalyst centric) to <BR>Cat code, falls the 
  shadow.<BR><BR>Chisel:<BR>&gt;$c-&gt;stash-&gt;{pager} =&gt; 
  $c-&gt;stash-&gt;{photos}-&gt;pager();<BR>&gt;shouldn't this be an assignment 
  rather than a fat-comma?<BR><BR>Good eyeballs! Yes. <BR><BR>&gt;I think you 
  need to lose the square brackets, <BR>&gt;and you will probably find you then 
  have a <BR>&gt;DBIx::Class::ResultSet, which does have the <BR>&gt;pager() 
  method. <BR><BR>When I do, I get this error:<BR>Caught exception in 
  Catapult::Controller::Photo::Gallery-&gt;display 
  "DBIx::Class::ResultSet::pager(): Can't create pager for non-paged 
  rs<BR><BR>Going back to the DBIx::Class Cookbook example, <BR>which is pretty 
  simple (no joins or anything), do I <BR>have the joins and the row settings in 
  the right place? <BR>I tried a few combos, and the one that at least doesn't 
  <BR>throw cat down the stairs is the one I have been 
  using:<BR><BR>&nbsp;&nbsp;&nbsp; $c-&gt;stash-&gt;{photos} = 
  [$c-&gt;model('CatapultDB::Photos')-&gt;search(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'gallery.id' =&gt; 
  $selected_gallery<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  },<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join&nbsp;&nbsp;&nbsp;&nbsp; 
  =&gt; [qw/ gallery /],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prefetch 
  =&gt; [qw/ gallery /],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rows 
  =&gt; 2,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; 
  )];<BR><BR>Much less hair 
now,<BR><BR>/dennis<BR><BR><BR></FONT></BLOCKQUOTE></BODY></HTML>