<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cakebaker &#187; view</title>
	<atom:link href="http://cakebaker.42dh.com/tags/view/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Render partial from an atom builder view</title>
		<link>http://cakebaker.42dh.com/2009/11/27/render-partial-from-an-atom-builder-view/</link>
		<comments>http://cakebaker.42dh.com/2009/11/27/render-partial-from-an-atom-builder-view/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:15:52 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1302</guid>
		<description><![CDATA[Thanks to the built-in AtomFeedHelper it is quite easy to generate an atom feed with Rails. Here an example from the API: # app/views/posts/index.atom.builder atom_feed do &#124;feed&#124; feed.title("My great blog!") feed.updated(@posts.first.created_at) @posts.each do &#124;post&#124; feed.entry(post) do &#124;entry&#124; entry.title(post.title) entry.content(post.body, :type =&#62; 'html') entry.author do &#124;author&#124; author.name("DHH") end end end end The code should be self-explanatory [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to the built-in <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html">AtomFeedHelper</a> it is quite easy to generate an atom feed with Rails. </p>
<p>Here an example from the API:</p>
<pre>
<code># app/views/posts/index.atom.builder
atom_feed do |feed|
  feed.title("My great blog!")
  feed.updated(@posts.first.created_at)

  @posts.each do |post|
    feed.entry(post) do |entry|
      entry.title(post.title)
      entry.content(post.body, :type =&gt; 'html')

      entry.author do |author|
        author.name("DHH")
      end
    end
  end
end</code>
</pre>
<p>The code should be self-explanatory (if not, please leave a comment). </p>
<p>Recently, I had two such views which were almost identical, the only difference was the feed title. And that&#8217;s of course not really <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a>. </p>
<p>One possible approach to fix this &#8220;issue&#8221; is to set an instance variable with the feed title in the controller and render the same view in both cases. As I don&#8217;t like to set view titles (resp. feed titles in this case) in the controller, I decided to use a partial. </p>
<p>And so I put the code from above into a partial (plus changing the instance variable &#8220;@posts&#8221; to a local variable &#8220;posts&#8221; and introducing a new local variable &#8220;feed_title&#8221;), and tried to use this partial (app/views/shared/_feed.atom.builder) in the following way:</p>
<pre>
<code># app/views/posts/index.atom.builder
render :partial =&gt; 'shared/feed', :locals =&gt; {:feed_title =&gt; "My Posts", :posts =&gt; @posts}</code>
</pre>
<p>Well, it didn&#8217;t work. No output was generated. </p>
<p>After experimenting a bit I found the following solution by moving the outer-most block definition from the partial to the views:</p>
<pre>
<code># app/views/posts/index.atom.builder
atom_feed do |feed|
  render :partial =&gt; 'shared/feed', :locals =&gt; {:feed =&gt; feed, :feed_title =&gt; "My Posts", :posts =&gt; @posts}
end</code>
</pre>
<p>I don&#8217;t know whether this is the best solution (probably not), but it is definitely better than what I had previously ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/11/27/render-partial-from-an-atom-builder-view/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Default views for extensions</title>
		<link>http://cakebaker.42dh.com/2009/07/02/default-views-for-extensions/</link>
		<comments>http://cakebaker.42dh.com/2009/07/02/default-views-for-extensions/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 15:41:54 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1218</guid>
		<description><![CDATA[I&#8217;m currently revamping the API of NoseRub to use CakePHP&#8217;s Router::parseExtensions() magic, i.e. if you append an extension like &#8220;.json&#8221; to the action you request, then CakePHP automagically sets the correct content type, and uses extension-specific layouts and views to render the result (e.g. if you request /example/action.json then the layout app/views/layouts/json/default.ctp and the view [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently revamping the API of <a href="http://noserub.com">NoseRub</a> to use CakePHP&#8217;s <a href="http://api.cakephp.org/class/router#method-RouterparseExtensions">Router::parseExtensions()</a> magic, i.e. if you append an extension like &#8220;.json&#8221; to the action you request, then CakePHP automagically sets the correct content type, and uses extension-specific layouts and views to render the result (e.g. if you request /example/action.json then the layout app/views/layouts/json/default.ctp and the view app/views/example/json/action.ctp are used by default). </p>
<p>That&#8217;s nice, however, in our case all JSON views are identical (the same applies for the XML views):</p>
<pre>
<code>// requires the JSON part from the Zend framework
App::import('Vendor', 'json', array('file' =&gt; 'Zend'.DS.'Json.php'));
echo Zend_Json::encode(array('data' =&gt; $data));</code>
</pre>
<p>And so following the default approach would lead to a lot of duplication and many unnecessary folders and view files. And that&#8217;s not that cool ;-)</p>
<p>After some experimentation I found a better way. </p>
<p>For each extension I created a folder with a default view:</p>
<pre>
<code>app
  views
    json
      default.ctp
    xml
      default.ctp</code>
</pre>
<p>json/default.ctp contains the code I have shown above, and xml/default.ctp would look like:</p>
<pre>
<code>echo $xml-&gt;serialize(array('data' =&gt; $data), array('format' =&gt; 'tags'));</code>
</pre>
<p>To tell CakePHP it should render those default views when there is not a more specific view, I added the following beforeRender() callback method to the AppController:</p>
<pre>
<code>// app/app_controller.php
class AppController extends Controller {
    public function beforeRender() {
        $pathToViewFile = dirname(__FILE__).DS.'views'.DS.$this-&gt;viewPath.DS.$this-&gt;action.'.ctp';
		
        if (!file_exists($pathToViewFile)) {
            $this-&gt;viewPath = $this-&gt;layoutPath;
            $this-&gt;action = 'default';
        }
    }
}</code>
</pre>
<p>Happy baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/07/02/default-views-for-extensions/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>An idea for loading helpers in the view</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/</link>
		<comments>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 15:20:15 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724</guid>
		<description><![CDATA[In the comments to my previous article, &#8220;An alternative to requestAction&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them in views. (Thanks to Rafael Bandeira and Tarique Sani) That&#8217;s indeed a bit illogical if you think about it. It would be more logical to define the [...]]]></description>
			<content:encoded><![CDATA[<p>In the comments to my previous article, &#8220;<a href="http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/">An alternative to requestAction</a>&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them in views. (Thanks to <a href="http://rafaelbandeira3.wordpress.com/">Rafael Bandeira</a> and <a href="http://www.sanisoft.com/blog/author/tariquesani/">Tarique Sani</a>)</p>
<p>That&#8217;s indeed a bit illogical if you think about it. It would be more logical to define the helpers directly where they are needed, in the views.</p>
<p>After some experimenting and digging in the source of the View class I found a relatively clean way to accomplish that by using a custom view class. </p>
<p>Ok, here is what I did. First I created a custom view class called &#8220;AppView&#8221; in app/views/app.php. It contains one method to load the helpers, which is later used in the views. I also had to override the constructor to support &#8220;global&#8221; helpers (i.e. they can be used in all views). So instead of defining them in the AppController they are now defined in the $helpers array of this custom view. FormHelper, HtmlHelper, and SessionHelper do not have to be defined, they are automatically loaded by CakePHP.</p>
<pre>
<code>// app/views/app.php
class AppView extends View {
    public $helpers = array('Navigation');
	
    public function __construct(&amp;$controller, $register = true) {
        $globalHelpers = $this-&gt;helpers;
        parent::__construct($controller, $register);
        $this-&gt;loadHelpers(array_merge($this-&gt;helpers, $globalHelpers));
    }
	
    public function loadHelpers($helperNames) {
        $helpers = $this-&gt;_loadHelpers($this-&gt;loaded, $helperNames);

        foreach ($helpers as $helper) {
            $name = str_replace('Helper', '', get_class($helper));
            $this-&gt;$name = $helper;
        }
    }
}</code>
</pre>
<p>To use this custom view class, I have to tell the AppController to do so by setting the $view property:</p>
<pre>
<code>// app/app_controller.php
class AppController extends Controller {
    public $view = 'App';
    ...
}</code>
</pre>
<p>And finally I can load and use the desired helpers in the views like:</p>
<pre>
<code>&lt;?php 
$this-&gt;loadHelpers(array('CamelCase')); 
echo $this-&gt;CamelCase-&gt;getSomething();
echo $this-&gt;Form-&gt;create('MyModel');
...
?&gt;</code>
</pre>
<p>As you can see from the example above, the usage of the helpers is different from what you are used to. Instead of $form-&gt;create() I used $this-&gt;Form-&gt;create(). It&#8217;s more to write, but I think it is more consistent with the rest of the framework. </p>
<p>What do you think about this approach?</p>
<p>Update (2008-08-28): Thanks to Rafael Bandeira&#8217;s idea it is no longer necessary to call the loadHelpers() method in your views, just copy the following method to the AppView and it will auto-load the helpers when they are needed:</p>
<pre>
<code>public function __get($property) {
    $this-&gt;loadHelpers(array($property));
    return $this-&gt;{$property};
}</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Setting the page title</title>
		<link>http://cakebaker.42dh.com/2008/05/28/setting-the-page-title/</link>
		<comments>http://cakebaker.42dh.com/2008/05/28/setting-the-page-title/#comments</comments>
		<pubDate>Wed, 28 May 2008 08:27:13 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=607</guid>
		<description><![CDATA[If you want to set the title of a page, you have three different ways to accomplish that. The first two approaches use the magic variable &#8220;title_for_layout&#8221; to set the title in the layout: &#60;title&#62; &#60;?php echo $title_for_layout;?&#62; &#60;/title&#62; You can set the value for this magic variable either in the controller: public $pageTitle = [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to set the title of a page, you have three different ways to accomplish that. </p>
<p>The first two approaches use the magic variable &#8220;title_for_layout&#8221; to set the title in the layout:</p>
<pre>
&lt;title&gt;
    &lt;?php echo $title_for_layout;?&gt;
&lt;/title&gt;
</pre>
<p>You can set the value for this magic variable either in the controller:</p>
<pre>
public $pageTitle = 'The title';  // same title for all actions

or

public function test() {
    $this-&gt;pageTitle = 'The title';
    ...
}
</pre>
<p>or in the view file:</p>
<pre>
&lt;?php $this-&gt;pageTitle = 'The title';?&gt;
...
</pre>
<p>The third, and last, approach uses a custom variable in the layout instead of the magic variable:</p>
<pre>
&lt;title&gt;
    &lt;?php echo $pageTitle;?&gt;
&lt;/title&gt;
</pre>
<p>Its value is then set in the controller, in the same way you put other data to the view:</p>
<pre>
public function test() {
    ...
    $this-&gt;set('pageTitle', 'The title');
}
</pre>
<p>Now, which approach should you use? I think it is a matter of preference. From a conceptual point of view I prefer the third approach as it doesn&#8217;t use any magic, but in practice I usually use the second (maybe this will change after this article *g*). The first approach I consider as a bad practice, because a controller doesn&#8217;t represent a page and hence it shouldn&#8217;t have a pageTitle property. </p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/05/28/setting-the-page-title/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Three new validation rules</title>
		<link>http://cakebaker.42dh.com/2008/05/21/three-new-validation-rules/</link>
		<comments>http://cakebaker.42dh.com/2008/05/21/three-new-validation-rules/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:32:18 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[deprecated]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=605</guid>
		<description><![CDATA[Recently, three new validation methods have been added to the core validation class and hence you can use three more validation rules in your models: boolean, inList, and time. boolean is self-explanatory: it validates whether a field contains a boolean value (i.e. 0, 1, &#8220;0&#8243;, &#8220;1&#8243;, false, or true). Example: var $validate = array('is_enabled' =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, three new validation methods have been added to the core validation class and hence you can use three more validation rules in your models: boolean, inList, and time. </p>
<p><strong>boolean</strong> is self-explanatory: it validates whether a field contains a boolean value (i.e. 0, 1, &#8220;0&#8243;, &#8220;1&#8243;, false, or true). Example:</p>
<pre>
var $validate = array('is_enabled' =&gt; array('rule' =&gt; array('boolean')));
</pre>
<p><strong>inList</strong> ensures that the respective field only contains a value from the defined array. It is case-sensitive, i.e. if you use the rule from the example below, then the value &#8220;Red&#8221; would be invalid.</p>
<pre>
var $validate = array('color' =&gt; array('rule' =&gt; array('inList', array('red', 'green', 'blue'))));
</pre>
<p><strong>time</strong> determines whether a field contains a valid time value. It supports both the 24 hour format (e.g. 08:10:10) and the 12 hour format (e.g. 8:10:10am). The minutes and seconds are optional in both cases.</p>
<pre>
var $validate = array('starttime' =&gt; array('rule' =&gt; array('time')));
</pre>
<p>Another recent change affected View::renderElement(): it has been deprecated in favor of View::element():</p>
<pre>
$this-&gt;renderElement('my_element', array('param1' =&gt; 'a value'));

becomes

$this-&gt;element('my_element', array('param1' =&gt; 'a value'));
</pre>
<p>I don&#8217;t know why View::renderElement() was deprecated and not View::element(), as I think the method name &#8220;renderElement&#8221; is more expressive than &#8220;element&#8221;.</p>
<p>Anyway, happy baking :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/05/21/three-new-validation-rules/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Detect the rendering of an error page</title>
		<link>http://cakebaker.42dh.com/2008/03/15/detect-the-rendering-of-an-error-page/</link>
		<comments>http://cakebaker.42dh.com/2008/03/15/detect-the-rendering-of-an-error-page/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 15:31:46 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/03/15/detect-the-rendering-of-an-error-page/</guid>
		<description><![CDATA[Yesterday, I ran into an endless loop in NoseRub while trying to run the migrations to set up the necessary tables. After debugging a while I found the cause for the endless loop: in the beforeRender() method of the AppController we create a model, and as there were no tables at that time, this failed [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I ran into an endless loop in <a href="http://noserub.com">NoseRub</a> while trying to run the migrations to set up the necessary tables. After debugging a while I found the cause for the endless loop: in the beforeRender() method of the AppController we create a model, and as there were no tables at that time, this failed and caused a &#8220;missing table&#8221; error. Usually, the corresponding error page is then rendered. And that&#8217;s it. But not in this case, due to a &#8220;feature&#8221; I was not aware of: before an error page is rendered, the beforeRender() method of the AppController is called. In this case, it caused again a &#8220;missing table&#8221; error, and so you have the loop ;-)</p>
<p>To prevent this effect, we have to detect the type of view which is rendered. The only way I found to accomplish this, is to check the viewPath, as shown in the following snippet:</p>
<pre>
// in app/app_controller.php
public function beforeRender() {
    if ($this-&gt;viewPath != 'errors') {
        // no error page
    }
}
</pre>
<p>It is probably rather rare you have to use this, but maybe it is useful for some.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/03/15/detect-the-rendering-of-an-error-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edit in place with JQuery and CakePHP</title>
		<link>http://cakebaker.42dh.com/2008/02/24/edit-in-place-with-jquery-and-cakephp/</link>
		<comments>http://cakebaker.42dh.com/2008/02/24/edit-in-place-with-jquery-and-cakephp/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 10:07:41 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/02/24/edit-in-place-with-jquery-and-cakephp/</guid>
		<description><![CDATA[Sometimes it is quite handy if the users of an application can simply click on some text to edit it. Adding such a feature to your application is not very difficult as you will see. At first we have to get the Jeditable plugin (plus the JQuery library if you don&#8217;t have it already) and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is quite handy if the users of an application can simply click on some text to edit it. Adding such a feature to your application is not very difficult as you will see.</p>
<p>At first we have to get the <a href="http://www.appelsiini.net/projects/jeditable">Jeditable</a> plugin (plus the <a href="http://jquery.com/">JQuery</a> library if you don&#8217;t have it already) and place it in app/webroot/js. In this folder we also create a js file which will contain the Javascript code we have to write (I will name this file example.js). </p>
<p>To use the Javascript files, we have to include them in the layout (or in the view, see <a href="http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/">&#8220;Referencing Javascript files&#8221;</a> for more information):</p>
<pre>
// app/views/layouts/default.ctp
&lt;?php echo $javascript-&gt;link(array('jquery-1.2.3', 'jquery.jeditable', 'example')); ?&gt;
</pre>
<p>Don&#8217;t forget to add the Javascript helper to the $helpers array of your (App)Controller.</p>
<p>The next step is to write the &#8220;normal&#8221; functionality of the application, in this example we simply list the titles of all posts. The controller (app/controllers/posts_controller.php):</p>
<pre>
class PostsController extends AppController {

    public function index() {
        $this-&gt;set('posts', $this-&gt;Post-&gt;find('all'));
    }
}
</pre>
<p>And the view (app/views/posts/index.ctp):</p>
<pre>
&lt;?php foreach ($posts as $post): ?&gt;
    &lt;div class="post" id="&lt;?php echo $post['Post']['id']; ?&gt;"&gt;&lt;?php echo $post['Post']['title']; ?&gt;&lt;/div&gt;
&lt;?php endforeach; ?&gt;
</pre>
<p>With that we are ready to add the edit in place functionality. Thanks to the Jeditable plugin this is an easy task: we only have to define the editable element(s), the url to which the changes should be posted, plus some parameters.</p>
<pre>
// app/webroot/js/example.js
$(function() {
    $('.post').editable('/posts/updateTitle', {
         id        : 'data[Post][id]',
         name      : 'data[Post][title]',
         type      : 'text',
         cancel    : 'Cancel',
         submit    : 'Save',
         tooltip   : 'Click to edit the title'
    });
});
</pre>
<p>I think this code is self-explanatory (if not, please leave a comment), so we can go on to implement the updateTitle action. We also add the RequestHandler component to our controller, so that the response of the updateTitle action automatically uses the ajax layout:</p>
<pre>
class PostsController extends AppController {
    public $components = array('RequestHandler');

    public function index() {
        $this-&gt;set('posts', $this-&gt;Post-&gt;find('all'));
    }

    public function updateTitle() {
        if ($this-&gt;data) {
            App::import('Core', 'sanitize');
            $title = Sanitize::clean($this-&gt;data['Post']['title']);

            $this-&gt;Post-&gt;id = $this-&gt;data['Post']['id'];
            $this-&gt;Post-&gt;saveField('title', $title);
            $this-&gt;set('posttitle', $title);
        }
    }
}
</pre>
<p>Last, but not least, we have to create a simple view for the updateTitle action (app/views/posts/update_title.ctp):</p>
<pre>
&lt;?php echo $posttitle;?&gt;
</pre>
<p>That&#8217;s it, our application now provides edit in place functionality. Happy baking :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/02/24/edit-in-place-with-jquery-and-cakephp/feed/</wfw:commentRss>
		<slash:comments>101</slash:comments>
		</item>
		<item>
		<title>Faster baking with bake</title>
		<link>http://cakebaker.42dh.com/2007/12/28/faster-baking-with-bake/</link>
		<comments>http://cakebaker.42dh.com/2007/12/28/faster-baking-with-bake/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 12:27:59 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/28/faster-baking-with-bake/</guid>
		<description><![CDATA[Some time ago some shortcuts were added to the bake script to make it possible to skip all those questions the bake script usually asks: cake bake model User cake bake controller Users scaffold cake bake view Users For more details on those shortcuts call the bake script with the help parameter like: cake bake [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago some shortcuts were added to the bake script to make it possible to skip all those questions the bake script usually asks:</p>
<pre>
cake bake model User
cake bake controller Users scaffold
cake bake view Users
</pre>
<p>For more details on those shortcuts call the bake script with the help parameter like:</p>
<pre>
cake bake model help
</pre>
<p>or have a look at <a href="http://cakebaker.42dh.com/2007/06/06/faster-baking-of-controllers-with-the-bake-shell-script/">Faster baking of controllers with the bake shell script</a> and <a href="http://cakebaker.42dh.com/2007/06/11/baking-views/">Baking views</a>.</p>
<p>Recently, a new shortcut was added which makes the aforementioned shortcuts (almost) obsolete. With the &#8220;all&#8221; parameter it is now possible to bake with one command a model plus the corresponding controller with its views:</p>
<pre>
cake bake all  // asks you for the model name
cake bake all User
</pre>
<p>This feature is currently only available in the development branch, but the next release is probably not that far away&#8230;</p>
<p>Happy baking :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/12/28/faster-baking-with-bake/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Rendering elements from controllers</title>
		<link>http://cakebaker.42dh.com/2007/12/21/rendering-elements-from-controllers/</link>
		<comments>http://cakebaker.42dh.com/2007/12/21/rendering-elements-from-controllers/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 08:06:41 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/21/rendering-elements-from-controllers/</guid>
		<description><![CDATA[If you work with Ajax you probably encountered situations when it would have been handy if you could render an element directly from the controller. But that was not possible. You had to use a view, and then from there you could render the element with renderElement(). In the meantime this feature has been added [...]]]></description>
			<content:encoded><![CDATA[<p>If you work with Ajax you probably encountered situations when it would have been handy if you could render an element directly from the controller. But that was not possible. You had to use a view, and then from there you could render the element with renderElement().</p>
<p>In the meantime this feature has been added to the development branch (I don&#8217;t know when) as I learned today from a <a href="https://trac.cakephp.org/ticket/3132#comment:4">comment</a> by gwoo.</p>
<p>If you have an element /app/views/elements/example.ctp in your application, then you can render it with the following code snippet from within your controller:</p>
<pre>
$this-&gt;render('/elements/example');
</pre>
<p>In the same way you can also render views which belong to other controllers.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/12/21/rendering-elements-from-controllers/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Code completion in views with Eclipse PDT</title>
		<link>http://cakebaker.42dh.com/2007/10/12/code-completion-in-views-with-eclipse-pdt/</link>
		<comments>http://cakebaker.42dh.com/2007/10/12/code-completion-in-views-with-eclipse-pdt/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 14:38:12 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/10/12/code-completion-in-views-with-eclipse-pdt/</guid>
		<description><![CDATA[If you use Eclipse PDT you probably noticed that there is no code completion in the view for helpers. The reason for that behavior is that Eclipse doesn&#8217;t know anything about CakePHP&#8217;s magic and so cannot provide code completion. Now someone called &#8220;voidstate&#8221; posted a little trick in the CakePHP Google Group which makes it [...]]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://www.eclipse.org/pdt">Eclipse PDT</a> you probably noticed that there is no code completion in the view for helpers. The reason for that behavior is that Eclipse doesn&#8217;t know anything about CakePHP&#8217;s magic and so cannot provide code completion. </p>
<p>Now someone called &#8220;voidstate&#8221; posted a <a href="http://groups.google.com/group/cake-php/browse_thread/thread/04b94b593714b394/9e06e1964e9877f2?lnk=raot#9e06e1964e9877f2">little trick</a> in the <a href="http://groups.google.com/group/cake-php">CakePHP Google Group</a> which makes it possible to get code completion in the view for helpers. For this purpose you have to create a PHP file somewhere in your project (it doesn&#8217;t matter where) with the following content:</p>
<pre>
&lt;?php
 // stop page loading
 exit; 

// reference helpers so Eclipse provides code completion
 $ajax = new AjaxHelper();
 $cache = new CacheHelper();
 $form = new FormHelper();
 $html = new HtmlHelper();
 $javascript = new JavascriptHelper();
 $number = new NumberHelper();
 $session = new SessionHelper();
 $text = new TextHelper();
 $time = new TimeHelper();
 ?&gt;
</pre>
<p>As soon as the file is stored, you should have code completion. Thanks to voidstate for this trick!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/10/12/code-completion-in-views-with-eclipse-pdt/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

