<?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: CakePHP Advanced Pagination &#8211; sort by derived field</title>
	<atom:link href="http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/feed/" rel="self" type="application/rss+xml" />
	<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/</link>
	<description>ABCoder - Coding is Simple as A b c</description>
	<lastBuildDate>Mon, 09 Jan 2012 02:12:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: thiagottjv</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-13370</link>
		<dc:creator>thiagottjv</dc:creator>
		<pubDate>Wed, 12 Oct 2011 15:09:40 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-13370</guid>
		<description>Hi, for me (using JOINS) i had to use the function like this:

function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array()) {
    if(!empty($extra[&#039;passit&#039;][&#039;sort&#039;])){
        $order = array(@$extra[&#039;passit&#039;][&#039;sort&#039;] =&gt; @$extra[&#039;passit&#039;][&#039;direction&#039;]);
    }
    $group = @$extra[&#039;group&#039;];
    
    if($extra[&#039;joins&#039;] != &#039;&#039;){
        $joins = @$extra[&#039;joins&#039;];
    }
    
    return $this-&gt;find(&#039;all&#039;, compact(&#039;conditions&#039;, &#039;fields&#039;, &#039;order&#039;, &#039;limit&#039;, &#039;page&#039;, &#039;recursive&#039;, &#039;group&#039;, &#039;joins&#039;));
}</description>
		<content:encoded><![CDATA[<p>Hi, for me (using JOINS) i had to use the function like this:</p>
<p>function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array()) {<br />
    if(!empty($extra['passit']['sort'])){<br />
        $order = array(@$extra['passit']['sort'] =&gt; @$extra['passit']['direction']);<br />
    }<br />
    $group = @$extra['group'];</p>
<p>    if($extra['joins'] != &#8221;){<br />
        $joins = @$extra['joins'];<br />
    }</p>
<p>    return $this-&gt;find(&#8216;all&#8217;, compact(&#8216;conditions&#8217;, &#8216;fields&#8217;, &#8216;order&#8217;, &#8216;limit&#8217;, &#8216;page&#8217;, &#8216;recursive&#8217;, &#8216;group&#8217;, &#8216;joins&#8217;));<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kadek</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-11409</link>
		<dc:creator>Kadek</dc:creator>
		<pubDate>Sat, 27 Aug 2011 08:28:11 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-11409</guid>
		<description>Hi, it&#039;s work but make my sql error when I try to click sortable link, because unknown colum &quot;Product.lowestprice&quot; in table Products.
How I can solved this problem? Thanks before</description>
		<content:encoded><![CDATA[<p>Hi, it&#8217;s work but make my sql error when I try to click sortable link, because unknown colum &#8220;Product.lowestprice&#8221; in table Products.<br />
How I can solved this problem? Thanks before</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-11343</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 24 Aug 2011 20:06:28 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-11343</guid>
		<description>Great article (and with great comments too : using Virtualfields does the trick).

How would we know we have to use virtual fields if we aren&#039;t aware of them and we are trying to solve a &quot;sorting&quot; issue ? Read this article.

Thank you !</description>
		<content:encoded><![CDATA[<p>Great article (and with great comments too : using Virtualfields does the trick).</p>
<p>How would we know we have to use virtual fields if we aren&#8217;t aware of them and we are trying to solve a &#8220;sorting&#8221; issue ? Read this article.</p>
<p>Thank you !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Omri Allouche</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-9490</link>
		<dc:creator>Omri Allouche</dc:creator>
		<pubDate>Thu, 02 Jun 2011 07:07:12 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-9490</guid>
		<description>I had a the same problem and managed to solve it without any need to change the links or the pagination process, using a nice tweak and ideas from this tutorial.

For this to magically work, one needs to set the value of $paginate[&#039;order&#039;] and unset $passedArgs[&#039;sort&#039;]. Simply insert the code below after setting up $paginate nd before activating paginate()


if(isset($this-&gt;passedArgs[&#039;sort&#039;])) {
	$dsort = $this-&gt;passedArgs[&#039;sort&#039;];
	unset($this-&gt;passedArgs[&#039;sort&#039;]);
	if(isset($this-&gt;passedArgs[&#039;direction&#039;])) {
		$this-&gt;paginate[&#039;order&#039;] = array($dsort =&gt; $this-&gt;passedArgs[&#039;direction&#039;]);
	} else {
		$this-&gt;paginate[&#039;order&#039;] = array($dsort =&gt; &#039;ASC&#039;);
	}
}
		
I hope it helps.

Cheers,
Omri</description>
		<content:encoded><![CDATA[<p>I had a the same problem and managed to solve it without any need to change the links or the pagination process, using a nice tweak and ideas from this tutorial.</p>
<p>For this to magically work, one needs to set the value of $paginate['order'] and unset $passedArgs['sort']. Simply insert the code below after setting up $paginate nd before activating paginate()</p>
<p>if(isset($this-&gt;passedArgs['sort'])) {<br />
	$dsort = $this-&gt;passedArgs['sort'];<br />
	unset($this-&gt;passedArgs['sort']);<br />
	if(isset($this-&gt;passedArgs['direction'])) {<br />
		$this-&gt;paginate['order'] = array($dsort =&gt; $this-&gt;passedArgs['direction']);<br />
	} else {<br />
		$this-&gt;paginate['order'] = array($dsort =&gt; &#8216;ASC&#8217;);<br />
	}<br />
}</p>
<p>I hope it helps.</p>
<p>Cheers,<br />
Omri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-9179</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Sun, 15 May 2011 21:43:35 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-9179</guid>
		<description>Hi.. Thanks a lot for this explanation. This helped me to fix another problem I was having.  I was trying to get this to work with some complex model associations.

I had Model 1 belongs to Model 2 belongs to Model 3.  I was paginating model 1, but I wanted to sort on Model 3. 

I was using bindModel in my controller and joins in my paginator variable to get out my data like this

[] =&gt; array(
   [Model 1] =&gt; array(),
   [Model 2] =&gt; array(),
   [Model 3] =&gt; array()
) 

but it still wasn&#039;t working.  So I tried your method, but the paginate override was screwing up the associations.  

So I took the joins out of the variable, and moved my bindModel call into the paginate function to get my associations and it worked!   

Maybe I missed something with your tutorial, but this was the only way I could get it working with my set up.  Thanks again!</description>
		<content:encoded><![CDATA[<p>Hi.. Thanks a lot for this explanation. This helped me to fix another problem I was having.  I was trying to get this to work with some complex model associations.</p>
<p>I had Model 1 belongs to Model 2 belongs to Model 3.  I was paginating model 1, but I wanted to sort on Model 3. </p>
<p>I was using bindModel in my controller and joins in my paginator variable to get out my data like this</p>
<p>[] =&gt; array(<br />
   [Model 1] =&gt; array(),<br />
   [Model 2] =&gt; array(),<br />
   [Model 3] =&gt; array()<br />
) </p>
<p>but it still wasn&#8217;t working.  So I tried your method, but the paginate override was screwing up the associations.  </p>
<p>So I took the joins out of the variable, and moved my bindModel call into the paginate function to get my associations and it worked!   </p>
<p>Maybe I missed something with your tutorial, but this was the only way I could get it working with my set up.  Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wpolscemamymocneseo</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-8343</link>
		<dc:creator>wpolscemamymocneseo</dc:creator>
		<pubDate>Wed, 12 Jan 2011 02:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-8343</guid>
		<description>Great article, but a frustrating read, due to the lack of proper punctuation in a lot of spots. Please close your quotations! If this article is following some sort of nouveau grammatical style, of which Iâ€™m not aware, I remain frustrated; however, I apologize.</description>
		<content:encoded><![CDATA[<p>Great article, but a frustrating read, due to the lack of proper punctuation in a lot of spots. Please close your quotations! If this article is following some sort of nouveau grammatical style, of which Iâ€™m not aware, I remain frustrated; however, I apologize.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ffyall</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-8313</link>
		<dc:creator>ffyall</dc:creator>
		<pubDate>Fri, 07 Jan 2011 17:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-8313</guid>
		<description>@dogmatic69 -&gt; life saver! tks</description>
		<content:encoded><![CDATA[<p>@dogmatic69 -&gt; life saver! tks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lucas</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-6878</link>
		<dc:creator>lucas</dc:creator>
		<pubDate>Fri, 26 Nov 2010 20:24:23 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-6878</guid>
		<description>thank dudes you rules
i took your ideas and pack them into

function hasField($fieldName) {
        return parent::hasField($fieldName) &#124;&#124; in_array($fieldName, $this-&gt;additional_fields);
    }</description>
		<content:encoded><![CDATA[<p>thank dudes you rules<br />
i took your ideas and pack them into</p>
<p>function hasField($fieldName) {<br />
        return parent::hasField($fieldName) || in_array($fieldName, $this-&gt;additional_fields);<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2010-07-20 &#171; Breyten&#8217;s Dev Blog</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-6741</link>
		<dc:creator>links for 2010-07-20 &#171; Breyten&#8217;s Dev Blog</dc:creator>
		<pubDate>Tue, 20 Jul 2010 11:05:49 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-6741</guid>
		<description>[...] CakePHP Advanced Pagination – sort by derived field Weird cake bug that hit me today. (tags: cakephp pagination bug) [...]</description>
		<content:encoded><![CDATA[<p>[...] CakePHP Advanced Pagination – sort by derived field Weird cake bug that hit me today. (tags: cakephp pagination bug) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sid</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-6728</link>
		<dc:creator>sid</dc:creator>
		<pubDate>Wed, 07 Jul 2010 10:39:53 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-6728</guid>
		<description>Thanks buddy for ur valuable article.</description>
		<content:encoded><![CDATA[<p>Thanks buddy for ur valuable article.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

