<?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>Web Development &#38; Stuff &#187; Programming</title>
	<atom:link href="http://web-development-blog.co.uk/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://web-development-blog.co.uk</link>
	<description>Some interesting findings from web-dev land...</description>
	<lastBuildDate>Thu, 22 Dec 2011 15:35:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CakePHP 1.3 Custom validation rule error &#8211; preg_match() Delimiter must not be alphanumeric or backslash</title>
		<link>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/</link>
		<comments>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 15:35:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=485</guid>
		<description><![CDATA[If you get this error:
1Warning: Warning &#40;2&#41;: preg_match&#40;&#41; &#91;&#60;a href='function.preg-match'&#62;function.preg-match&#60;/a&#62;&#93;: Delimiter must not be alphanumeric or backslash in &#91;/var/www/vhosts/h2oservices.com/httpdocs/cake/libs/model/model.php, line 2611&#93;
When trying to use a custom validation rule, make sure the method visibility is set to public.
So this should work:
123public function myCustomValidateRule&#40;&#41;&#123;
&#160; &#160; // Custom validation code
&#125;
It seems protected visibility works on some versions of [...]]]></description>
			<content:encoded><![CDATA[<p>If you get this error:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">Warning<span class="sy0">:</span> Warning <span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="kw3">preg_match</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st_h">'function.preg-match'</span><span class="sy0">&gt;</span>function<span class="sy0">.</span>preg<span class="sy0">-</span>match<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span><span class="br0">&#93;</span><span class="sy0">:</span> Delimiter must not be alphanumeric or backslash in <span class="br0">&#91;</span><span class="sy0">/</span><span class="kw2">var</span><span class="sy0">/</span>www<span class="sy0">/</span>vhosts<span class="sy0">/</span>h2oservices<span class="sy0">.</span>com<span class="sy0">/</span>httpdocs<span class="sy0">/</span>cake<span class="sy0">/</span>libs<span class="sy0">/</span>model<span class="sy0">/</span>model<span class="sy0">.</span>php<span class="sy0">,</span> line <span class="nu0">2611</span><span class="br0">&#93;</span></div></td></tr></tbody></table></div>
<p>When trying to use a custom validation rule, make sure the method visibility is set to public.</p>
<p>So this should work:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">public</span> <span class="kw2">function</span> myCustomValidateRule<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Custom validation code</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>It seems protected visibility works on some versions of PHP (5.2.11 tested and working) and not others.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ternary in PHP Heredoc</title>
		<link>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/</link>
		<comments>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 15:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=473</guid>
		<description><![CDATA[It can&#8217;t be done using the normal Ternary operator but you can emulate it with:
12345678910111213// So instead of:

$str = &#60;&#60;&#60;HTML
{$a ? 1 : 2}
HTML;

// You can do:

$values = array&#40;'1', '2'&#41;;

$str = &#60;&#60;&#60;HTML
{$values[$a]}
HTML;
]]></description>
			<content:encoded><![CDATA[<p>It can&#8217;t be done using the normal Ternary operator but you can emulate it with:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">// So instead of:</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$a ? 1 : 2}<br />
HTML</span><span class="sy0">;</span><br />
<br />
<span class="co1">// You can do:</span><br />
<br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'1'</span><span class="sy0">,</span> <span class="st_h">'2'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$values[$a]}<br />
HTML</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual/non existent model fields using CakePHP Security Component</title>
		<link>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/</link>
		<comments>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 08:07:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=463</guid>
		<description><![CDATA[If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.
In this example I&#8217;m ignoring the security_code (captcha) field, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.</p>
<p>In this example I&#8217;m ignoring the security_code (captcha) field, which obviously I don&#8217;t store anywhere in the database table:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Security</span><span class="sy0">-&gt;</span><span class="me1">disabledFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'Enquiry.security_code'</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP virtual field count another model/table</title>
		<link>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/</link>
		<comments>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 10:37:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=428</guid>
		<description><![CDATA[Just managed to count another table using a model virtual field, obviously preserving the association with the sub query conditions.
So in my ProductTemplate model I have this:
123var $virtualFields = array&#40;
&#160; &#160; 'page_count' =&#62; 'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'
&#160; &#41;;
The nice thing about this is you can use the field with [...]]]></description>
			<content:encoded><![CDATA[<p>Just managed to count another table using a <a href="http://book.cakephp.org/view/1608/Virtual-fields">model virtual field</a>, obviously preserving the association with the sub query conditions.</p>
<p>So in my ProductTemplate model I have this:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> <span class="re0">$virtualFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'page_count'</span> <span class="sy0">=&gt;</span> <span class="st_h">'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>The nice thing about this is you can use the field with the CakePHP Model::find ordering and with the pagination component.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving CakePHP HABTM models with join table data</title>
		<link>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/</link>
		<comments>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 18:16:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=402</guid>
		<description><![CDATA[You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.
In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. 
Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too [...]]]></description>
			<content:encoded><![CDATA[<p>You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.</p>
<p>In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. </p>
<p>Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too if it makes sense in your context:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">class</span> User <span class="kw2">extends</span> AppModel <span class="br0">&#123;</span><br />
&nbsp; <br />
&nbsp; <span class="kw2">public</span> <span class="re0">$hasAndBelongsToMany</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'Video'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'with'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'order'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo.order'</span><br />
&nbsp; &nbsp; <span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Make sure you do a $model->saveAll() in the controller:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">User</span><span class="sy0">-&gt;</span><span class="me1">saveAll</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">data</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Success message</span><br />
&nbsp; <span class="co1">// Redirect &nbsp; &nbsp; </span><br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Error message</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>The trick is in the naming of the form input elements. The format is Video.X.UsersVideo.field_name.</p>
<p>Here&#8217;s an example:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.id'</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.video_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="re0">$videos</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; <br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.order'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="kw3">range</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="kw3">count</span><span class="br0">&#40;</span><span class="re0">$videos</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.user_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'hidden'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'value'</span> <span class="sy0">=&gt;</span> <span class="re0">$user</span><span class="br0">&#91;</span><span class="st_h">'User'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>Which outputs:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="br0">&#91;</span>User<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<span class="br0">&#91;</span>Video<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>UsersVideo<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>video_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">9</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>order<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>user_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div></td></tr></tbody></table></div>
<p>This will add a record to the join table with the order value.</p>
<p>Obviously you can expand on this to save more users_videos records during the same saveAll call.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CKEditor in iFrame / jQuery UI dialog top offset bug</title>
		<link>http://web-development-blog.co.uk/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/</link>
		<comments>http://web-development-blog.co.uk/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 16:37:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=395</guid>
		<description><![CDATA[I had a couple of CKEditors in a jQuery UI dialog box today. The dialog box contained an iFrame with the actual CKEditors inside that.
On the odd occasion when the modal box opened (tested in FireFox 3.6 on the Mac and PC) the vertical scroll position of the iFrame would not be at the top. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a couple of CKEditors in a jQuery UI dialog box today. The dialog box contained an iFrame with the actual CKEditors inside that.</p>
<p>On the odd occasion when the modal box opened (tested in FireFox 3.6 on the Mac and PC) the vertical scroll position of the iFrame would not be at the top. Instead it was focused on one of the lower CKEditors.</p>
<p>After some Googling and hacking and still no solution I placed this in each CKeditor onReady/instanceReady callback, which did the trick:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">CKEditor<span class="sy0">.</span>on<span class="br0">&#40;</span><span class="st0">&quot;instanceReady&quot;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>event<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; $<span class="br0">&#40;</span>window<span class="br0">&#41;</span><span class="sy0">.</span>scrollTop<span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/15/ckeditor-in-iframe-jquery-ui-dialog-top-offset-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Insert CakePHP ACO nodes using CakeDC migrations plugin</title>
		<link>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/</link>
		<comments>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 11:24:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=380</guid>
		<description><![CDATA[I&#8217;m in the situation where most of my CMS components are extensible CakePHP plugs. 
I&#8217;ve just started to use the CakeDC migrations plugin (been meaning to for a long time as I always loved Rails migrations).
I had previously automated the insertion of plugin ACO node records using a Bash script that chugged through a stack [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the situation where most of my CMS components are extensible CakePHP plugs. </p>
<p>I&#8217;ve just started to use the CakeDC migrations plugin (been meaning to for a long time as I always loved Rails migrations).</p>
<p>I had previously automated the insertion of plugin ACO node records using a Bash script that chugged through a stack of &#8216;cake acl create aco bla/bla bla&#8217; commands.</p>
<p>After playing with the migration callbacks for a while I figured out how to insert ACO nodes. The killer part of this process is <strong>remembering to attach the Tree behavior</strong> to the ACL model. Otherwise your ACO tree hierarchy will get toasted!</p>
<p>My advice would be to <strong>SQL dump your database/ACO table</strong> before playing with this:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co2"># Migration after callback</span><br />
<span class="co2"># Inserts a node for the Dashboard controller and then a single admin_index child action. </span><br />
<br />
<span class="kw2">public</span> <span class="kw2">function</span> after<span class="br0">&#40;</span><span class="re0">$direction</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="re0">$aco</span> <span class="sy0">=</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">generateModel</span><span class="br0">&#40;</span><span class="st_h">'Aco'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="co1">// Be sure to attach this. Otherwise it's bye-bye tree hierarchy!!</span><br />
&nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">Behaviors</span><span class="sy0">-&gt;</span><span class="me1">attach</span><span class="br0">&#40;</span><span class="st_h">'Tree'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="re0">$direction</span> <span class="sy0">==</span> <span class="st_h">'up'</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Insert ACO node for dashboard controller.</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'parent_id'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'alias'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'Dashboard'</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">save</span><span class="br0">&#40;</span><span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Insert ACO node for dashboard admin_index action.</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'parent_id'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">id</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$data</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'alias'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'admin_index'</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">create</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">save</span><span class="br0">&#40;</span><span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; <span class="br0">&#125;</span> <span class="kw1">elseif</span><span class="br0">&#40;</span> <span class="re0">$direction</span> <span class="sy0">==</span> <span class="st_h">'down'</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="re0">$dashboard</span> <span class="sy0">=</span> <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">findByAlias</span><span class="br0">&#40;</span><span class="st_h">'Dashboard'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// Remove ACO nodes.</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="sy0">!</span><span class="kw3">empty</span><span class="br0">&#40;</span><span class="re0">$dashboard</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">deleteAll</span><span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'Aco.parent_id'</span> <span class="sy0">=&gt;</span> <span class="re0">$dashboard</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$aco</span><span class="sy0">-&gt;</span><span class="me1">delete</span><span class="br0">&#40;</span><span class="re0">$dashboard</span><span class="br0">&#91;</span><span class="st_h">'Aco'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span class="kw1">return</span> <span class="kw2">true</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Coupling this with a create_table in the up stage of the migration will mean plugin installations should be a 2 stage process.</p>
<p>1) Import plugin using Piston/SVN external.<br />
2) Run the install migration creating table(s) and registering permit-table actions (ACO nodes).</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/12/insert-cakephp-aco-nodes-using-cakedc-migrations-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP HABTM find with conditions and containable behavior</title>
		<link>http://web-development-blog.co.uk/2010/09/14/cakephp-habtm-find-with-conditions-and-containable-behavior/</link>
		<comments>http://web-development-blog.co.uk/2010/09/14/cakephp-habtm-find-with-conditions-and-containable-behavior/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 15:00:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=369</guid>
		<description><![CDATA[If you&#8217;re using the CakePHP Containable behavio(u)r and trying to query with conditions across a Has and Belongs To Many association, you need to specify you wish to contain the dynamically bound model records, before you do the actual find.
Here&#8217;s one example from the book that doesn&#8217;t work with Containable:
123456$this-&#62;Recipe-&#62;bindModel&#40;array&#40;'hasOne' =&#62; array&#40;'RecipesTag'&#41;&#41;&#41;;

$this-&#62;Recipe-&#62;find&#40;'all', array&#40;
&#160; &#160; 'fields' [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using the CakePHP Containable behavio(u)r and trying to query with conditions across a Has and Belongs To Many association, you need to specify you wish to contain the dynamically bound model records, before you do the actual find.</p>
<p>Here&#8217;s one example from the book <strong>that doesn&#8217;t work with Containable</strong>:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Recipe</span><span class="sy0">-&gt;</span><span class="me1">bindModel</span><span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'hasOne'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'RecipesTag'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Recipe</span><span class="sy0">-&gt;</span><span class="me1">find</span><span class="br0">&#40;</span><span class="st_h">'all'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'fields'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'Recipe.*'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'conditions'</span><span class="sy0">=&gt;</span>array<span class="br0">&#40;</span><span class="st_h">'RecipesTag.tag_id'</span><span class="sy0">=&gt;</span><span class="nu0">124</span><span class="br0">&#41;</span> <span class="co1">// id of Dessert</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>With Containable you need to specify that you want to include the dynamically bound join table (RecipesTag) records, otherwise the search will not work:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Recipe</span><span class="sy0">-&gt;</span><span class="me1">bindModel</span><span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'hasOne'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'RecipesTag'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="co1">// Here we specify we want the RecipesTag records.</span><br />
<span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Recipe</span><span class="sy0">-&gt;</span><span class="me1">contain</span><span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'RecipesTag'</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Recipe</span><span class="sy0">-&gt;</span><span class="me1">find</span><span class="br0">&#40;</span><span class="st_h">'all'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'fields'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'Recipe.*'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'conditions'</span><span class="sy0">=&gt;</span>array<span class="br0">&#40;</span><span class="st_h">'RecipesTag.tag_id'</span><span class="sy0">=&gt;</span><span class="nu0">124</span><span class="br0">&#41;</span> <span class="co1">// id of Dessert</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/09/14/cakephp-habtm-find-with-conditions-and-containable-behavior/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Stop Javascript event bubbling / propagation with nested html elements using jQuery</title>
		<link>http://web-development-blog.co.uk/2010/07/28/stop-javascript-event-bubbling-propagation-nested-html-elements/</link>
		<comments>http://web-development-blog.co.uk/2010/07/28/stop-javascript-event-bubbling-propagation-nested-html-elements/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:51:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=359</guid>
		<description><![CDATA[You can stop nested elements triggering their parent element event handlers (DOM bubbling) using this handy jQuery method:
http://api.jquery.com/event.stopImmediatePropagation/
I ran into this issue whilst working on a calendar/scheduling app. Where day containing elements needed click events and their child elements needed click events too. 
Love the jQuery ;]
]]></description>
			<content:encoded><![CDATA[<p>You can stop nested elements triggering their parent element event handlers (DOM bubbling) using this handy jQuery method:</p>
<p><a href="http://api.jquery.com/event.stopImmediatePropagation/">http://api.jquery.com/event.stopImmediatePropagation/</a></p>
<p>I ran into this issue whilst working on a calendar/scheduling app. Where day containing elements needed click events and their child elements needed click events too. </p>
<p>Love the jQuery ;]</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/07/28/stop-javascript-event-bubbling-propagation-nested-html-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File uploads to PHP scripts hang in Safari bug</title>
		<link>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/</link>
		<comments>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 17:37:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Linux servers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=354</guid>
		<description><![CDATA[I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.
https://bugs.webkit.org/show_bug.cgi?id=5760
I added this to the virtual host declaration in my Apache config file to fix it:
123456&#60;VirtualHost x.x.x.x:x&#62;

&#160; &#160; # Prevent Safari from hanging on uploads
&#160; &#160; BrowserMatch &#160;Safari&#160; nokeepalive

&#60;/VirtualHost&#62;
]]></description>
			<content:encoded><![CDATA[<p>I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.</p>
<p><a href="https://bugs.webkit.org/show_bug.cgi?id=5760">https://bugs.webkit.org/show_bug.cgi?id=5760</a></p>
<p>I added this to the virtual host declaration in my Apache config file to fix it:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">&lt;</span>VirtualHost x.x.x.x:x<span class="sy0">&gt;</span><br />
<br />
&nbsp; &nbsp; <span class="co0"># Prevent Safari from hanging on uploads</span><br />
&nbsp; &nbsp; BrowserMatch &nbsp;Safari&nbsp; nokeepalive<br />
<br />
<span class="sy0">&lt;/</span>VirtualHost<span class="sy0">&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/06/15/file-uploads-to-php-scripts-hang-in-safari-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

