<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Squio.blog &#187; cakephp</title>
	<atom:link href="http://squio.nl/tags/webdev/php/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://squio.nl</link>
	<description>Creative internet development</description>
	<lastBuildDate>Mon, 24 Jan 2011 21:08:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>	<div id='fb-root'></div>
					<script type='text/javascript'>
						window.fbAsyncInit = function()
						{
							FB.init({appId: 139820809411699, status: true, cookie: true, xfbml: true});
						};
						(function()
						{
							var e = document.createElement('script'); e.async = true;
							e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
							document.getElementById('fb-root').appendChild(e);
						}());
					</script>	
						<item>
		<title>Choice of PHP Frameworks</title>
		<link>http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/</link>
		<comments>http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 22:57:59 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://squio.nl/?p=511</guid>
		<description><![CDATA[As of today there is a Tweet Poll running with the question: Which PHP opensource framework do you mostly use? An interesting question because the market of PHP frameworks appears pretty fragmented after 750+ votes are cast. Leading is Zend Framework (does this qualify as Open Source?), followed by Symfony, Cake PHP, CodeIgniter, all around [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div class="wp-caption alignright" style="width: 178px"><a href="http://en.wikipedia.org/wiki/Image:PHP-logo.svg"><img class="  " title="PHP" src="http://squio.nl/blog/wp-content/2009/11/300px-PHP-logo.svg.png" alt="PHP" width="168" height="89" /></a><p class="wp-caption-text">Image via Wikipedia</p></div>
</div>
<p>As of today there is a Tweet Poll running with the question: <a href="http://twtpoll.com/r/lxt2xe">Which PHP opensource framework do you mostly use</a>?<br />
An interesting question because the market of PHP frameworks appears pretty fragmented after 750+ votes are cast. Leading is <a class="zem_slink" title="Zend Framework" rel="homepage" href="http://framework.zend.com/">Zend Framework</a> (does this qualify as Open Source?), followed by <a class="zem_slink" title="Symfony" rel="homepage" href="http://www.symfony-project.org/">Symfony</a>, <a class="zem_slink" title="CakePHP" rel="homepage" href="http://www.cakephp.org">Cake PHP</a>, <a class="zem_slink" title="CodeIgniter" rel="homepage" href="http://codeigniter.com/%20">CodeIgniter</a>, all around 10%. There are also a few stray ones: I don&#8217;t consider <a class="zem_slink" title="PEAR" rel="wikipedia" href="http://en.wikipedia.org/wiki/PEAR">PEAR</a> a framework and the choice &#8220;my own&#8221; can be disputed as well.</p>
<p>For now there is no clear winner, something I already had that <em>gut feeling</em> about. Wonder where this is going to stabilize (and of course, how representative the twitter votes are anyway). See for yourself, the embedded graph below should stay up to date and you may cast your vote if you ike.</p>
<p><script src="http://twtpoll.com/js/badge.js" type="text/javascript"></script> <script src="http://twtpoll.com/badge/?twt=lxt2xe&amp;s=250&amp;b=1&amp;bt=1" type="text/javascript"></script></p>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://completeopensource.blogspot.com/2009/08/php-frameworks-comparison-part-1.html">PHP Frameworks Comparison &#8211; Part 1</a> (completeopensource.blogspot.com)</li>
<li class="zemanta-article-ul-li"><a href="http://r.zemanta.com/?u=http%3A//www.infoworld.com/d/developer-world/php-frameworks-square-238%3Fsource%3Drss_infoworld_news&amp;a=8836140&amp;rid=c124d219-2297-436d-93ff-fa65a03e5444&amp;e=43d3d441e00308fdc5878dd34499e174">PHP frameworks square off</a> (infoworld.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.noupe.com/php/discussing-php-frameworks.html">Discussing PHP Frameworks: What, When, Why and Which?</a> (noupe.com)</li>
<li class="zemanta-article-ul-li"><a href="http://woorkup.com/2009/11/17/exploring-php-frameworks-codeigniter/">Exploring PHP Frameworks: CodeIgniter</a> (woorkup.com)</li>
<li class="zemanta-article-ul-li"><a href="http://woorkup.com/2009/10/10/top-best-php-frameworks-to-build-quickly-complex-web-applications/">Top Best PHP Frameworks to build quickly complex web applications</a> (woorkup.com)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/c124d219-2297-436d-93ff-fa65a03e5444/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=c124d219-2297-436d-93ff-fa65a03e5444" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Choice+of+PHP+Frameworks+http%3A%2F%2Fsquio.nl%2F%3Fp%3D511" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Choice+of+PHP+Frameworks+http%3A%2F%2Fsquio.nl%2F%3Fp%3D511" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/&amp;title=Choice+of+PHP+Frameworks" title="Post to StumbleUpon">Stumble This Post</a></p></div><div class='wpfblike' style='height: 40px;'><fb:like href='http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><img src="http://squio.nl/blog/?ak_action=api_record_view&id=511&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2009/11/10/choice-of-php-frameworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using pagination with CakePHP&#8217;s finderQuery SQL</title>
		<link>http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/</link>
		<comments>http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 10:19:52 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[finderQuery]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[Nigel McNie]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[patch]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/</guid>
		<description><![CDATA[Update February 2009: this article is now about a year old and deals with an early beta versions of CakePHP 1.2. In the mean time, CakePHP 1.2 has been released with many improvements and great documentation. Please don&#8217;t use this patch, use this instead. I&#8217;ll leave the article below for reference. Cakephp lets you define [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; width: 100px; height: 100px;" src="http://squio.nl/blog/wp-content/2008/02/cake12b.png" alt="Cakephp 1.2" /></p>
<p><strong>Update</strong> February 2009: this article is now about a year old and deals with an early beta versions of <a class="zem_slink" title="CakePHP" rel="homepage" href="http://www.cakephp.org">CakePHP</a> 1.2. In the mean time, CakePHP 1.2 has been released with many improvements and great <a href="http://book.cakephp.org/">documentation</a>. Please don&#8217;t use this <a class="zem_slink" title="Patch (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Patch_%28computing%29">patch</a>, use <a title="Custom Query Pagination" href="http://book.cakephp.org/view/249/Custom-Query-Pagination">this</a> instead. I&#8217;ll leave the article below for reference.</p>
<p>Cakephp lets you define various kinds of associations between models. The principle is really simple, just define arrays like <code>$hasMany</code> in your main model, where associations with other models are defined.</p>
<p>For most purposes this does the trick, most associations are made by convention, but you can  override these as well for e.g. database (foreign-) keys.</p>
<p>From there on, you can use all cake built-in functionality to retrieve model data. One such feature is auto pagination, where the page size is set through the value of the <code>limit</code> field in the model&#8217;s definition.</p>
<p>If you&#8217;re crafting something really complex, you can define your own SQL query in the <code>finderQuery</code> field. This is very nice, but the trade-of is that the other fields are ignored in the query. And if fields <code>limit</code> and <code>offset</code> are ignored, you no longer get auto pagination.</p>
<p>The patch below fixes this for the current development tree of CakePHP 1.2 (revision 6461).<br />
<span id="more-148"></span></p>
<p>This patch inspects the <code>finderQuery</code> SQL and applies the values of the relevant model fields if the SQL does not contain a value for <code>LIMIT</code> and <code>ORDER BY</code>, respectively.</p>
<p>So now you have:</p>
<ul>
<li><code>limit</code> value from model applied, unless LIMIT is defined in <code>finderQuery</code></li>
<li><code>order</code> value from model or application query applied, unless ORDER BY is defined in <code>finderQuery</code></li>
<li><code>offset</code> value from model or application query applied, unless LIMIT is defined in <code>finderQuery</code></li>
</ul>
<p>Patch for <code>/cake/libs/model/datasources/dbo_source.php</code></p>
<p><!-- 	.li1 {background:#f4f4f4;} 	.li2 {background:#ffffff;} 	/* GeSHi (c) Nigel McNie 2004 (<a href="http://qbnz.com/highlighter" rel="nofollow">http://qbnz.com/highlighter</a>) */ .diff .imp {font-weight: bold; color: red;} .diff .kw1 {color: #aaaaaa; font-style: italic;} .diff .kw2 {color: #dd6611;} .diff .re0 {color: #440088;} .diff .re1 {color: #991111;} .diff .re2 {color: #00b000;} .diff .re3 {color: #888822;} .diff .re4 {color: #888822;} .diff .re5 {color: #0011dd;} .diff .re6 {color: #440088;} .diff .re7 {color: #991111;} .diff .re8 {color: #00b000;} .diff .re9 {color: #888822;} --></p>
<div class="pastes">
<div class="body">
<div class="diff" style="overflow: auto; font-family: monospace; width: 100%; white-space: nowrap;">
<ol>
<li class="li1">
<div class="de1">Index: dbo_source.php</div>
</li>
<li class="li2">
<div class="de2">===================================================================</div>
</li>
<li class="li1">
<div class="de1"><span class="re3">&#8212; dbo_source.php  <span class="br0">(</span>revision <span class="nu0">6461</span><span class="br0">)</span></span></div>
</li>
<li class="li2">
<div class="de2"><span class="re4">+++ dbo_source.php  <span class="br0">(</span>working copy<span class="br0">)</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="re6">@@ <span class="nu0">-1046</span>,<span class="nu0">7</span> <span class="nu0">+1046</span>,<span class="nu0">19</span> @@</span></div>
</li>
<li class="li2"></li>
<li class="li1">
<div class="de1">if <span class="br0">(</span>$external &amp;&amp; isset<span class="br0">(</span>$assocData<span class="br0">[</span>'finderQuery'<span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></div>
</li>
<li class="li2">
<div class="de2">if <span class="br0">(</span>!empty<span class="br0">(</span>$assocData<span class="br0">[</span>'finderQuery'<span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re7">-            return $assocData<span class="br0">[</span>'finderQuery'<span class="br0">]</span>;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+            $qry = $assocData<span class="br0">[</span>'finderQuery'<span class="br0">]</span>;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+            // if no ORDER is specified in finderquery, use model definition</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+            if <span class="br0">(</span>!preg_match<span class="br0">(</span>&#8216;/\sORDER\s+BY\s/i&#8217;, $qry<span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+               $orderData = <span class="br0">(</span>empty<span class="br0">(</span>$queryData<span class="br0">[</span>'order'<span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> ? $assocData<span class="br0">[</span>'order'<span class="br0">]</span> : $queryData<span class="br0">[</span>'order'<span class="br0">]</span>;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+               $qry .= &#8216; &#8216; . $this-&gt;order<span class="br0">(</span>$orderData<span class="br0">)</span>;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+            <span class="br0">}</span></span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+            // if no LIMIT/OFFSET is specified in finderquery, use model definition</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+            if <span class="br0">(</span>!preg_match<span class="br0">(</span>&#8216;/\sLIMIT\s/i&#8217;, $qry<span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+               $limitData = <span class="br0">(</span>empty<span class="br0">(</span>$queryData<span class="br0">[</span>'limit'<span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> ? @$assocData<span class="br0">[</span>'limit'<span class="br0">]</span> : $queryData<span class="br0">[</span>'limit'<span class="br0">]</span>;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+               $offsetData = <span class="br0">(</span>empty<span class="br0">(</span>$queryData<span class="br0">[</span>'offset'<span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> ? @$assocData<span class="br0">[</span>'offset'<span class="br0">]</span> : $queryData<span class="br0">[</span>'offset'<span class="br0">]</span>;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+               $qry .= &#8216; &#8216; . $this-&gt;limit<span class="br0">(</span>$limitData, $offsetData<span class="br0">)</span>;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re8">+            <span class="br0">}</span></span></div>
</li>
<li class="li2">
<div class="de2"><span class="re8">+            return $qry;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">}</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">}</span></div>
</li>
<li class="li1"></li>
<li class="li2"></li>
</ol>
</div>
</div>
</div>
<div class="tags"><a href="http://technorati.com/tag/cakephp" rel="tag">cakephp</a> <a href="http://technorati.com/tag/patch" rel="tag"> patch</a> <a href="http://technorati.com/tag/mvc" rel="tag"> mvc</a> <a href="http://technorati.com/tag/php" rel="tag"> php</a> <a href="http://technorati.com/tag/finderQuery" rel="tag"> finderQuery</a> <a href="http://technorati.com/tag/pagination" rel="tag"> pagination</a></div><br />
[ratings]</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/99c0e8ef-9e3b-45e6-a5d9-f3862367c442/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=99c0e8ef-9e3b-45e6-a5d9-f3862367c442" alt="Reblog this post [with Zemanta]" /></a></div>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL+http%3A%2F%2Fsquio.nl%2F%3Fp%3D148" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL+http%3A%2F%2Fsquio.nl%2F%3Fp%3D148" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/&amp;title=Using+pagination+with+CakePHP%E2%80%99s+finderQuery+SQL" title="Post to StumbleUpon">Stumble This Post</a></p></div><div class='wpfblike' style='height: 40px;'><fb:like href='http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><img src="http://squio.nl/blog/?ak_action=api_record_view&id=148&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2008/02/26/using-pagination-with-cakephps-finderquery-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cakephp: isAjax weirdness</title>
		<link>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/</link>
		<comments>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 11:43:20 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/</guid>
		<description><![CDATA[Currently, I&#8217;m doing a project in CakePHP. There&#8217;s lots to say about cake, here just a quick note, for myself or for anyone in case you are running into the same problem. Situation: you are using the Ajax helper, which contains a method isAjax() &#8211; returns true if the request was an Ajax request. Typically, [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://squio.nl/blog/wp-content/2008/02/cake12b.png' alt='Cakephp 1.2' style="float:right;width:100px;height:100px" />Currently, I&#8217;m doing a project in CakePHP.</p>
<p>There&#8217;s lots to say about cake, here just a quick note, for myself or for anyone in case you are running into the same problem.</p>
<p>Situation: you are using the Ajax helper, which contains a method <code>isAjax()</code> &#8211; returns <code>true</code> if the request was an Ajax request.</p>
<p>Typically, you use this method inside a view, to conditionally render content for regular/ajax views. Example:</p>
<p><code>...<br />
if (! $ajax->isAjax()) {<br />
  // render general page stuff<br />
}<br />
  // render stuff for both regular- and ajax view<br />
...<br />
</code></p>
<p>My problem was that the <code>isAjax()</code> call never returned true, regardless of ajax/regular request method.</p>
<p>The solution appears to be really simple: you should include the <code>'RequestHandler'</code> component in your controller class. This one took me way too long to figure out! </p>
<p><code><br />
	public $components = array (<br />
		'Auth',<br />
		'Cookie',<br />
		'RequestHandler'<br />
	);<br />
</code></p>
<p><strong>Update</strong> my situation was even worse than described above; I use a redirect between controllers within an Ajax call, something which is officially supported by Cake 1.2. This worked just fine in Safari, but not in Firefox (and Opera) &#8211; these browsers would not load the Ajax view but rather the complete page, almost crashing the server by consuming huge amounts of memory.</p>
<p>Read on&#8230;<span id="more-146"></span></p>
<p>Lots and lots of troubleshooting did not help, after which I tried my last bet: update Cake to the current development build.<br />
And that appeared to be <em>the</em> solution! Not only solves this the Ajax detection problem, the whole application seems to be much more efficient too.</p>
<p>The Cake SVN repository is organised somewhat unconventional. A quick recipe for getting the last development revision&#8230;</p>
<p>The repository is rooted at <a href="https://svn.cakephp.org/repo/">https://svn.cakephp.org/repo/</a>.</p>
<p>There are the common subdirectories, amongst others:</p>
<ul>
<li>branches</li>
<li>tags</li>
<li>trunk</li>
</ul>
<p>In this case, Trunk contains the last released (beta) versions, while branches contain, well, the trunk repository.<br />
So in order to get the current HEAD release, you have to get the source from <a href="https://svn.cakephp.org/repo/branches/1.2.x.x/">/branches/1.2.x.x</a>.</p>
<p>Command line:</p>
<p><code>svn co <a href="https://svn.cakephp.org/repo/branches/1.2.x.x/" rel="nofollow">https://svn.cakephp.org/repo/branches/1.2.x.x/</a></code></p>
<p>I&#8217;m working with revision 6461, highly recommended!</p>
<div class="tags"><a href="http://technorati.com/tag/cakephp" rel="tag">cakephp</a> <a href="http://technorati.com/tag/mvc" rel="tag"> mvc</a> <a href="http://technorati.com/tag/ajax" rel="tag"> ajax</a> <a href="http://technorati.com/tag/isajax" rel="tag"> isajax</a></div><br />
[ratings]</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Cakephp%3A+isAjax+weirdness+http%3A%2F%2Fsquio.nl%2F%3Fp%3D146" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Cakephp%3A+isAjax+weirdness+http%3A%2F%2Fsquio.nl%2F%3Fp%3D146" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to StumbleUpon">Stumble This Post</a></p></div><div class='wpfblike' style='height: 40px;'><fb:like href='http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><img src="http://squio.nl/blog/?ak_action=api_record_view&id=146&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

