<?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>Sun, 25 Jul 2010 05:39:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<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>
	<item>
		<title>By: dogmatic69</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-6667</link>
		<dc:creator>dogmatic69</dc:creator>
		<pubDate>Thu, 13 May 2010 00:43:42 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-6667</guid>
		<description>why not just upgrade to 1.3 and use virtualFields http://book.cakephp.org/view/1608/Virtual-fields</description>
		<content:encoded><![CDATA[<p>why not just upgrade to 1.3 and use virtualFields <a href="http://book.cakephp.org/view/1608/Virtual-fields" rel="nofollow">http://book.cakephp.org/view/1608/Virtual-fields</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bernhard</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-5745</link>
		<dc:creator>bernhard</dc:creator>
		<pubDate>Tue, 09 Mar 2010 21:09:08 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-5745</guid>
		<description>shoot. do not know how to add code snippets here. One more try:

Add this

// redefine this in your model for additional fields
var $additionalFields = array();

function hasField($name) {
	// handle fields
	if(parent::hasField($name)) {
		return true;
	}
	// maybe this model has a field that is added by a custom query
	return in_array($name, $this-&gt;additionalFields);
}

to AppModel

and 
var $additionalFields = array(&#039;count_stn&#039;, &#039;sum_stn&#039;);
to your Models</description>
		<content:encoded><![CDATA[<p>shoot. do not know how to add code snippets here. One more try:</p>
<p>Add this</p>
<p>// redefine this in your model for additional fields<br />
var $additionalFields = array();</p>
<p>function hasField($name) {<br />
	// handle fields<br />
	if(parent::hasField($name)) {<br />
		return true;<br />
	}<br />
	// maybe this model has a field that is added by a custom query<br />
	return in_array($name, $this-&gt;additionalFields);<br />
}</p>
<p>to AppModel</p>
<p>and<br />
var $additionalFields = array(&#8216;count_stn&#8217;, &#8216;sum_stn&#8217;);<br />
to your Models</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bernhard</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-5744</link>
		<dc:creator>bernhard</dc:creator>
		<pubDate>Tue, 09 Mar 2010 21:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-5744</guid>
		<description>I liked the hasField idea, and improved it a bit.
In the AppModel class I added
additionalFields);
	}
?&gt;

This allowes you to use additional fields in your models by just adding 


As far as I can see it from here, no modifications in the views are needed for asc / desc.</description>
		<content:encoded><![CDATA[<p>I liked the hasField idea, and improved it a bit.<br />
In the AppModel class I added<br />
additionalFields);<br />
	}<br />
?&gt;</p>
<p>This allowes you to use additional fields in your models by just adding </p>
<p>As far as I can see it from here, no modifications in the views are needed for asc / desc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adnan</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-4496</link>
		<dc:creator>adnan</dc:creator>
		<pubDate>Thu, 28 Jan 2010 04:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-4496</guid>
		<description>@kkruit, thanks for your hint. I&#039;ll try it.</description>
		<content:encoded><![CDATA[<p>@kkruit, thanks for your hint. I&#8217;ll try it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kkruit</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-4490</link>
		<dc:creator>kkruit</dc:creator>
		<pubDate>Thu, 28 Jan 2010 00:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-4490</guid>
		<description>oops forgot to mention that code would be in the model you are paginating.</description>
		<content:encoded><![CDATA[<p>oops forgot to mention that code would be in the model you are paginating.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kkruit</title>
		<link>http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/comment-page-1/#comment-4489</link>
		<dc:creator>kkruit</dc:creator>
		<pubDate>Thu, 28 Jan 2010 00:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://abcoder.com/?p=446#comment-4489</guid>
		<description>You can overwrite the hasField function and just do something like:

[php]function hasField($fieldName){
     if(parent::hasField($fieldName))
          return true;
     else
          switch($fieldName){
               case &quot;lowestprice&quot;:
               case &quot;Custom.field_name1&quot;:
               case &quot;Custom.field_name2&quot;:
               case &quot;Custom.field_name3&quot;:
                    return true;
               default:
                    return false;
          }
     return false; // for good measure
}[/php]</description>
		<content:encoded><![CDATA[<p>You can overwrite the hasField function and just do something like:</p>
<pre class="brush: php;">function hasField($fieldName){
     if(parent::hasField($fieldName))
          return true;
     else
          switch($fieldName){
               case &quot;lowestprice&quot;:
               case &quot;Custom.field_name1&quot;:
               case &quot;Custom.field_name2&quot;:
               case &quot;Custom.field_name3&quot;:
                    return true;
               default:
                    return false;
          }
     return false; // for good measure
}</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
