<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Customising Baked Views in CakePHP</title>
	<atom:link href="http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/</link>
	<description>Learnings and Teachings on Web Application Development &#38; CakePHP</description>
	<lastBuildDate>Thu, 29 Jul 2010 07:25:11 +0200</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Hunter Cochran</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-272</link>
		<dc:creator>Hunter Cochran</dc:creator>
		<pubDate>Sat, 10 Jan 2009 19:47:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-272</guid>
		<description>hi
nm11i5pp8t7mkyuy
good luck</description>
		<content:encoded><![CDATA[<p>hi<br />
nm11i5pp8t7mkyuy<br />
good luck</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-34</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Fri, 12 Sep 2008 00:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-34</guid>
		<description>Hi Daniel,
I&#039;ve written a quick post for you to show you one way of &lt;a href=&quot;http://www.neilcrookes.com/2008/09/12/recording-created_by-and-modified_by/&quot; rel=&quot;nofollow&quot;&gt;recording created_by and modified_by data&lt;/a&gt; in your application.
Hope it helps (and works).</description>
		<content:encoded><![CDATA[<p>Hi Daniel,<br />
I&#8217;ve written a quick post for you to show you one way of <a href="http://www.neilcrookes.com/2008/09/12/recording-created_by-and-modified_by/" rel="nofollow">recording created_by and modified_by data</a> in your application.<br />
Hope it helps (and works).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-33</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 09 Sep 2008 05:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-33</guid>
		<description>Hey Neil, nice tutorial. I was wondering if you&#039;d be willing to post your code that handles created_by, modified_by etc - that would really help me, as i am quite new to cake, but loving it

Thanks</description>
		<content:encoded><![CDATA[<p>Hey Neil, nice tutorial. I was wondering if you&#8217;d be willing to post your code that handles created_by, modified_by etc &#8211; that would really help me, as i am quite new to cake, but loving it</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david b.</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-23</link>
		<dc:creator>david b.</dc:creator>
		<pubDate>Mon, 11 Aug 2008 06:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-23</guid>
		<description>I don&#039;t mind that you improve the code, certainly bake customisations can be a whole post. We have an administrator template and with your post we save a lot of time to customize the views after baking</description>
		<content:encoded><![CDATA[<p>I don&#8217;t mind that you improve the code, certainly bake customisations can be a whole post. We have an administrator template and with your post we save a lot of time to customize the views after baking</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-22</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Fri, 08 Aug 2008 20:07:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-22</guid>
		<description>Hi David, thanks for your reply and for pointing out my bug. You&#039;re right about the referer function. I&#039;ve wrapped your code snippet in &lt;code&gt; tags to format it better, hope you don&#039;t mind. I keep meaning to blog about some more of my bake customisations, but haven&#039;t found the time lately. I&#039;ve been focusing too much on learning about Agile and not enough time coding.</description>
		<content:encoded><![CDATA[<p>Hi David, thanks for your reply and for pointing out my bug. You&#8217;re right about the referer function. I&#8217;ve wrapped your code snippet in &lt;code&gt; tags to format it better, hope you don&#8217;t mind. I keep meaning to blog about some more of my bake customisations, but haven&#8217;t found the time lately. I&#8217;ve been focusing too much on learning about Agile and not enough time coding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david b.</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-21</link>
		<dc:creator>david b.</dc:creator>
		<pubDate>Fri, 08 Aug 2008 16:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-21</guid>
		<description>Thanks for your script! I make a little modification in your code and have a little bug, $this-&gt;referer is a function. I pass the field to save because we have several flags fields like status, deleted, etc...

&lt;code&gt;
function change_status_to($toStatus = null, $id = null, $field = null) {
  if( !is_null($id) &#124;&#124; !is_null($toStatus) &#124;&#124; !is_null($field) ) {
    $this-&gt;{$this-&gt;modelClass}-&gt;id = $id;
    $data = array($this-&gt;modelClass=&gt;array($field =&gt; $toStatus));
    if($this-&gt;{$this-&gt;modelClass}-&gt;save($data, false)) {
      $this-&gt;Session-&gt;setFlash(”Record has been saved”,’flash_success’);
    } else {
      $this-&gt;Session-&gt;setFlash(”Record could NOT be saved”,’flash_info’);
    }
  } else {
    $this-&gt;Session-&gt;setFlash(’Id or Status not specified’,&#039;flash_failure’);
  }
  $this-&gt;redirect($this-&gt;referer());
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for your script! I make a little modification in your code and have a little bug, $this-&gt;referer is a function. I pass the field to save because we have several flags fields like status, deleted, etc&#8230;</p>
<p><code><br />
function change_status_to($toStatus = null, $id = null, $field = null) {<br />
  if( !is_null($id) || !is_null($toStatus) || !is_null($field) ) {<br />
    $this->{$this->modelClass}->id = $id;<br />
    $data = array($this->modelClass=>array($field => $toStatus));<br />
    if($this->{$this->modelClass}->save($data, false)) {<br />
      $this->Session->setFlash(”Record has been saved”,’flash_success’);<br />
    } else {<br />
      $this->Session->setFlash(”Record could NOT be saved”,’flash_info’);<br />
    }<br />
  } else {<br />
    $this->Session->setFlash(’Id or Status not specified’,'flash_failure’);<br />
  }<br />
  $this->redirect($this->referer());<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-20</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Thu, 07 Aug 2008 19:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-20</guid>
		<description>Hi David, thanks for your comment. For the active field I tend to show the current ‘active’ status of a record with red or green icon in the actions column of the index view, and clicking on the icon toggles the status between active (green) and inactive (red).

To do this I just add a method to the app_controller like this (untested, but you get the idea):

[Edit: fixed bug, thanks david]

&lt;code&gt;function change_status_to($toStatus = null, $id = null) {
  if($id &amp;&amp; $toStatus) {
    $this-&gt;{$this-&gt;modelClass}-&gt;id = $id;
    $data = array($this-&gt;modelClass=&gt;array(&#039;active&#039;=&gt;$toStatus));
    if($this-&gt;{$this-&gt;modelClass}-&gt;save($data, false)) {
      $this-&gt;Session-&gt;setFlash(&quot;Record #$id has been $toStatus&quot;,&#039;flash_ok&#039;);
    } else {
      $this-&gt;Session-&gt;setFlash(&quot;Record #$id could NOT be $toStatus&quot;,&#039;flash_warning&#039;);
    }
  } else {
    $this-&gt;Session-&gt;setFlash(&#039;Id or Status not specified&#039;,&#039;flash_warning&#039;);
  }
  $this-&gt;redirect($this-&gt;referer());
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi David, thanks for your comment. For the active field I tend to show the current ‘active’ status of a record with red or green icon in the actions column of the index view, and clicking on the icon toggles the status between active (green) and inactive (red).</p>
<p>To do this I just add a method to the app_controller like this (untested, but you get the idea):</p>
<p>[Edit: fixed bug, thanks david]</p>
<p><code>function change_status_to($toStatus = null, $id = null) {<br />
  if($id &#038;&#038; $toStatus) {<br />
    $this->{$this->modelClass}->id = $id;<br />
    $data = array($this->modelClass=>array('active'=>$toStatus));<br />
    if($this->{$this->modelClass}->save($data, false)) {<br />
      $this->Session->setFlash("Record #$id has been $toStatus",'flash_ok');<br />
    } else {<br />
      $this->Session->setFlash("Record #$id could NOT be $toStatus",'flash_warning');<br />
    }<br />
  } else {<br />
    $this->Session->setFlash('Id or Status not specified','flash_warning');<br />
  }<br />
  $this->redirect($this->referer());<br />
}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david b.</title>
		<link>http://www.neilcrookes.com/2008/04/17/customising-baked-views-in-cakephp/comment-page-1/#comment-19</link>
		<dc:creator>david b.</dc:creator>
		<pubDate>Wed, 06 Aug 2008 19:27:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=5#comment-19</guid>
		<description>Your post is great! How do you control the fields like active throw a behaviour?

Regards!!</description>
		<content:encoded><![CDATA[<p>Your post is great! How do you control the fields like active throw a behaviour?</p>
<p>Regards!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
