<?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>Coding! don&#039;t ask, we&#039;re too good at it</description>
	<lastBuildDate>Wed, 09 May 2012 18:28:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Ganesh</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field#comment-18275</link>
		<dc:creator>Ganesh</dc:creator>
		<pubDate>Wed, 09 May 2012 13:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-18275</guid>
		<description>hi,
Thanks for great articular but m getting error,
&quot;Parse error: syntax error, unexpected T_VARIABLE calendar_accounts_controller.php on line 28&quot;
any clue it shows error for &quot;passit&quot;
Controller Code:

class CalendarAccountsController extends CalendarAppController
{
    var $name = &#039;CalendarAccounts&#039;;
    var $components = array(&#039;RequestHandler&#039;);
    var $paginate = array(&#039;order&#039; =&gt; array(
                                                &#039;email&#039; =&gt; &#039;asc&#039;
                                ),
                           &#039;fields&#039; =&gt; array(
                                                &#039;if(ISNULL(`PopEmailAlias`.`email_address`) , `ClientUser`.`email_address`, `PopEmailAlias`.`email_address`) as email&#039;,
                                                //&#039;email&#039;,
                                                &#039;CalendarAccount.*&#039;,
                                                &#039;ClientUser.email_address&#039;,&#039;ClientUser.client_domain_id&#039;,
                                                &#039;ClientDomain.id&#039;,&#039;ClientDomain.name&#039;,
                                                &#039;PopEmailAlias.email_address&#039;,&#039;PopEmailAlias.client_domain_id&#039;,//&#039;PopEmailAlias.id&#039;,
                                                &#039;PopEmailAliasDomain.id&#039;,&#039;PopEmailAliasDomain.name&#039;
                                        ),
                                &#039;passit&#039; =&gt; $this-&gt;passedArgs
                        );</description>
		<content:encoded><![CDATA[<p>hi,<br />
Thanks for great articular but m getting error,<br />
&#8220;Parse error: syntax error, unexpected T_VARIABLE calendar_accounts_controller.php on line 28&#8243;<br />
any clue it shows error for &#8220;passit&#8221;<br />
Controller Code:</p>
<p>class CalendarAccountsController extends CalendarAppController<br />
{<br />
    var $name = &#8216;CalendarAccounts&#8217;;<br />
    var $components = array(&#8216;RequestHandler&#8217;);<br />
    var $paginate = array(&#8216;order&#8217; =&gt; array(<br />
                                                &#8216;email&#8217; =&gt; &#8216;asc&#8217;<br />
                                ),<br />
                           &#8216;fields&#8217; =&gt; array(<br />
                                                &#8216;if(ISNULL(`PopEmailAlias`.`email_address`) , `ClientUser`.`email_address`, `PopEmailAlias`.`email_address`) as email&#8217;,<br />
                                                //&#8217;email&#8217;,<br />
                                                &#8216;CalendarAccount.*&#8217;,<br />
                                                &#8216;ClientUser.email_address&#8217;,'ClientUser.client_domain_id&#8217;,<br />
                                                &#8216;ClientDomain.id&#8217;,'ClientDomain.name&#8217;,<br />
                                                &#8216;PopEmailAlias.email_address&#8217;,'PopEmailAlias.client_domain_id&#8217;,//&#8217;PopEmailAlias.id&#8217;,<br />
                                                &#8216;PopEmailAliasDomain.id&#8217;,'PopEmailAliasDomain.name&#8217;<br />
                                        ),<br />
                                &#8216;passit&#8217; =&gt; $this-&gt;passedArgs<br />
                        );</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ferdinand Afan</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field#comment-17891</link>
		<dc:creator>Ferdinand Afan</dc:creator>
		<pubDate>Mon, 07 May 2012 13:07:01 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-17891</guid>
		<description>After I originally commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get four emails with the same comment. Is there any means you&#039;ll be able to take away me from that service? Thanks!</description>
		<content:encoded><![CDATA[<p>After I originally commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get four emails with the same comment. Is there any means you&#8217;ll be able to take away me from that service? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zelfs als edele metalen</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field#comment-16129</link>
		<dc:creator>Zelfs als edele metalen</dc:creator>
		<pubDate>Tue, 17 Apr 2012 00:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-16129</guid>
		<description>Iâ€™m impressed, I need to say. Really rarely will i go through a blog thatâ€™s both educative and interesting, and without a doubt, you&#039;ve hit the nail on the head. Your current concept is definitely excellent; the thing is something which not enough people are talking intelligently about. I&#039;m very happy that stumbled across it in my try to find something about it.</description>
		<content:encoded><![CDATA[<p>Iâ€™m impressed, I need to say. Really rarely will i go through a blog thatâ€™s both educative and interesting, and without a doubt, you&#8217;ve hit the nail on the head. Your current concept is definitely excellent; the thing is something which not enough people are talking intelligently about. I&#8217;m very happy that stumbled across it in my try to find something about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pankaj gupta</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field#comment-15887</link>
		<dc:creator>pankaj gupta</dc:creator>
		<pubDate>Sat, 17 Mar 2012 13:54:28 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-15887</guid>
		<description>great job it saved my efforts and time thanks a lot</description>
		<content:encoded><![CDATA[<p>great job it saved my efforts and time thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thiagottjv</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field#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-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-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-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-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-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>
</channel>
</rss>

