<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Pagination of data from a HABTM relationship</title>
	<atom:link href="http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:27:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-143577</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 08 Jan 2010 15:25:44 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-143577</guid>
		<description>@Regis: You are welcome!</description>
		<content:encoded><![CDATA[<p>@Regis: You are welcome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Regis</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-143502</link>
		<dc:creator>Regis</dc:creator>
		<pubDate>Thu, 07 Jan 2010 04:12:20 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-143502</guid>
		<description>Thank you very much for this!! It was very helpful :-)</description>
		<content:encoded><![CDATA[<p>Thank you very much for this!! It was very helpful :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-142930</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 28 Dec 2009 15:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-142930</guid>
		<description>@KillerSponge: I&#039;m glad to hear this article was helpful for you :)</description>
		<content:encoded><![CDATA[<p>@KillerSponge: I&#8217;m glad to hear this article was helpful for you :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KillerSponge</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-142870</link>
		<dc:creator>KillerSponge</dc:creator>
		<pubDate>Sun, 27 Dec 2009 12:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-142870</guid>
		<description>I can&#039;t thank you enough for this little tutorial. I&#039;ve searched for hours for a suitable and relatively neat solution. Thank you!</description>
		<content:encoded><![CDATA[<p>I can&#8217;t thank you enough for this little tutorial. I&#8217;ve searched for hours for a suitable and relatively neat solution. Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The World of Dan &#187; Blog Archive &#187; Three and a half days coding</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-138260</link>
		<dc:creator>The World of Dan &#187; Blog Archive &#187; Three and a half days coding</dc:creator>
		<pubDate>Sat, 17 Oct 2009 15:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-138260</guid>
		<description>[...] on HABTM relations such as the one between the Tag and Story models. After some research, however, I was able to find a solution to the problem. I don&#8217;t in any way understand how this works, all I know is that it does. Add to this a list [...]</description>
		<content:encoded><![CDATA[<p>[...] on HABTM relations such as the one between the Tag and Story models. After some research, however, I was able to find a solution to the problem. I don&#8217;t in any way understand how this works, all I know is that it does. Add to this a list [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-133370</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 24 Jul 2009 09:47:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-133370</guid>
		<description>@Jean-Philippe: You are welcome!</description>
		<content:encoded><![CDATA[<p>@Jean-Philippe: You are welcome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jean-Philippe Sirois</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-133320</link>
		<dc:creator>Jean-Philippe Sirois</dc:creator>
		<pubDate>Thu, 23 Jul 2009 13:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-133320</guid>
		<description>Awesome tutotrial. Can&#039;t be more simple. 

Great thanks for this, helping me a lot making my first search HABTM Search system in Cake.

I really love your website!</description>
		<content:encoded><![CDATA[<p>Awesome tutotrial. Can&#8217;t be more simple. </p>
<p>Great thanks for this, helping me a lot making my first search HABTM Search system in Cake.</p>
<p>I really love your website!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-131269</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 25 Jun 2009 14:28:34 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-131269</guid>
		<description>@matthew: Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>@matthew: Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthew r</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-131234</link>
		<dc:creator>matthew r</dc:creator>
		<pubDate>Thu, 25 Jun 2009 04:19:47 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-131234</guid>
		<description>I wanted to chime in here to say that I found this post and the resulting discussion in the comments useful. In the particular project I&#039;m finishing up now, I have a Product model that has a HABTM relationship with both Suppliers and Locations, and my product search page, using the default controller pagination, was simply not working. I eventually realized that I needed to define paginateCount() and paginate() methods in my Product model, adding the necessary &quot;group&quot; clause that the default pagination doesn&#039;t respect.

That is, I had this in my controller:
&lt;code&gt;
var $paginate = array(
  ...
  &#039;group&#039; =&gt; &#039;Product.id&#039;
  ...
);
&lt;/code&gt;
But it wasn&#039;t working. Instead I had to do this in models/product.php:
&lt;code&gt;
 function paginateCount($conditions, $recursive, $extra) {
     $parameters = compact(&#039;conditions&#039;);
     if ($recursive != $this-&gt;recursive) {
         $parameters[&#039;recursive&#039;] = $recursive;
     }
     $all = $this-&gt;find(&#039;all&#039;, array_merge($parameters, $extra, array(&#039;group&#039;=&gt;&#039;Product.id&#039;)));
     return sizeof($all);
 }
 
 function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) {
     $parameters = compact(&#039;conditions&#039;, &#039;fields&#039;, &#039;order&#039;, &#039;limit&#039;, &#039;page&#039;);
     if ($recursive != $this-&gt;recursive) {
         $parameters[&#039;recursive&#039;] = $recursive;
     }
     return $this-&gt;find(&#039;all&#039;, array_merge($parameters, $extra, array(&#039;group&#039;=&gt;&#039;Product.id&#039;)));
 }
&lt;/code&gt;

Note that this is almost the exact same code as in Controller::paginate() (starting around line 1077) but just with the addition of the group parameter being specified manually. I don&#039;t know why the group parameter wasn&#039;t making it all the way through Controller::paginate(), but this worked for me and I&#039;m posting here in case it helps somebody else.</description>
		<content:encoded><![CDATA[<p>I wanted to chime in here to say that I found this post and the resulting discussion in the comments useful. In the particular project I&#8217;m finishing up now, I have a Product model that has a HABTM relationship with both Suppliers and Locations, and my product search page, using the default controller pagination, was simply not working. I eventually realized that I needed to define paginateCount() and paginate() methods in my Product model, adding the necessary &#8220;group&#8221; clause that the default pagination doesn&#8217;t respect.</p>
<p>That is, I had this in my controller:<br />
<pre><code>var $paginate = array(
  ...
  'group' =&gt; 'Product.id'
  ...
);</code></pre><br />
But it wasn&#8217;t working. Instead I had to do this in models/product.php:<br />
<pre><code>function paginateCount($conditions, $recursive, $extra) {
     $parameters = compact('conditions');
     if ($recursive != $this-&gt;recursive) {
         $parameters['recursive'] = $recursive;
     }
     $all = $this-&gt;find('all', array_merge($parameters, $extra, array('group'=&gt;'Product.id')));
     return sizeof($all);
 }
 
 function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) {
     $parameters = compact('conditions', 'fields', 'order', 'limit', 'page');
     if ($recursive != $this-&gt;recursive) {
         $parameters['recursive'] = $recursive;
     }
     return $this-&gt;find('all', array_merge($parameters, $extra, array('group'=&gt;'Product.id')));
 }</code></pre>
<p>Note that this is almost the exact same code as in Controller::paginate() (starting around line 1077) but just with the addition of the group parameter being specified manually. I don&#8217;t know why the group parameter wasn&#8217;t making it all the way through Controller::paginate(), but this worked for me and I&#8217;m posting here in case it helps somebody else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/comment-page-2/#comment-122130</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 02 Mar 2009 16:36:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/#comment-122130</guid>
		<description>@mike: You are welcome!</description>
		<content:encoded><![CDATA[<p>@mike: You are welcome!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
