<?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>Cake Bakery</title>
	<atom:link href="http://cakebakery.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebakery.net</link>
	<description>Recipes for Development with CakePHP</description>
	<lastBuildDate>Wed, 22 Jul 2009 15:20:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>What to do to welcome Cake3?</title>
		<link>http://cakebakery.net/2009/07/22/what-to-do-to-welcome-cake3/</link>
		<comments>http://cakebakery.net/2009/07/22/what-to-do-to-welcome-cake3/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 15:02:37 +0000</pubDate>
		<dc:creator>Dirk Olbertz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cakebakery.net/?p=14</guid>
		<description><![CDATA[In an interview, Nate Abele made some very interesting outlooks towards Cake3.
And although I really appreciate this modern approach, I&#8217;m also scared how much work needs to be done to make NoseRub compatible with Cake3.
I should invest a lot more time into UnitTests and tests with Selenium in order to be prepared to find all [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://debuggable.com/posts/Cake_3_interview_with_Nate_Abele:4a665a5e-5bfc-4e42-96ee-6d284834cda3">interview</a>, Nate Abele made some very interesting outlooks towards Cake3.</p>
<p>And although I really appreciate this modern approach, I&#8217;m also scared how much work needs to be done to make <a href="http://noserub.com/">NoseRub</a> compatible with Cake3.</p>
<p>I should invest a lot more time into UnitTests and tests with Selenium in order to be prepared to find all the nasty side effects that might arise from such a giant move towards Cake3.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebakery.net/2009/07/22/what-to-do-to-welcome-cake3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Themes in CakePHP</title>
		<link>http://cakebakery.net/2009/07/06/how-to-use-themes-in-cakephp/</link>
		<comments>http://cakebakery.net/2009/07/06/how-to-use-themes-in-cakephp/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:38:20 +0000</pubDate>
		<dc:creator>Dirk Olbertz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cakebakery.net/?p=7</guid>
		<description><![CDATA[Similar to Wordpress Themes, CakePHP offers developers to implement a theme system for their applications.
We used this built in Themes support for NoseRub. Admins of a network should be able to add their own theme, so that the NoseRub installation matches their CI. And users should have the possibility to choose the look of their [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to Wordpress <em>Themes</em>, CakePHP offers developers to implement a theme system for their applications.</p>
<p>We used this built in Themes support for <a href="http://noserub.com/">NoseRub</a>. Admins of a network should be able to add their own theme, so that the NoseRub installation matches their CI. And users should have the possibility to choose the look of their profile page from a list of given themes.</p>
<p>All templates for websites that Cake renders, are called <em>Views</em> and are organized in the following folder: <code>/app/views/</code>. CSS and Javascript can be found in <code>/app/webroot/</code>.</p>
<p>To enable support for themes in CakePHP, you have to change the View class for that controller. But you can also do this directly in the AppController:</p>
<pre name="code" class="php">
class AppController extends Controller {
    public $view = 'Theme';
    ...
}
</pre>
<p>Before rendering a page, you now need to tell CakePHP, which theme should be used. We introduce a default theme in NoseRub and set this also directly in the AppController:</p>
<pre name="code" class="php">
class AppController extends Controller {
    public $view = 'Theme';
    public $theme = 'default';
    ...
}
</pre>
<p>This way, you can choose another theme at any place in your controller. If you want to display the profile page of a user with the theme that the user choosed, you can do this like this:</p>
<pre name="code" class="php">
class UsersController extends AppController {
    public $uses = array('User');

    public function view($username) {
        $user = $this->find('first', array(
            'conditions' => array(
                'User.username' => $username
            )
        ));
        $this->set('user', $user);

        // todo: check that user exists before proceeding!
        // todo: check that value of user theme is valid

        $this->theme = $user['User']['theme'];
    }
}
</pre>
<p>CakePHP is now looking for the views in the following folders: <code>/app/views/themed/[theme name]/</code> and <code>/app/webroot/themed/[theme name]/</code>. If the themes&#8217;s name is <em>green</em> CakePHP would look for the default layout (as no other layout is specified here) in <code>/app/views/themed/green/layouts/default.ctp</code> and the to be rendered view in <code>/app/views/themed/green/users/view.ctp</code>.</p>
<p>The really great thing about this is, that CakePHP always looks for the version without <code>themed</code> in the path, if it cannot find the path with <code>themed</code> in it. This way, the themes can be pretty small, because you just need to change the things you really need to. For some cases, you might even only need to include a CSS file into a new theme! (Think <a href="http://www.csszengarden.com/">CSS ZenGarden</a>&#8230;)</p>
<p>This fallback mechanism also works for Javascript and CSS files. In NoseRub, we render the JS tags with the following two lines in an element:<br />
<code name="code" class="php"><br />
echo $javascript->link('theme.js');<br />
echo $javascript->link('noserub.js');<br />
</code></p>
<p>In <code>/app/webroot/js/theme.js</code> we placed an empty file, but CakePHP will deliver a theme specific JS, if <code>theme.js</code> is included in that theme.</p>
<p>The only real disadvantage of Cake&#8217;s Themes is, that you always have to spread the file of your theme in two different folders (<code>/app/views/</code> and <code>/app/webroot/</code>). This is much simpler in Wordpress.<br />
But you gain a lot of security, because the PHP code in your views are not publicly accessible, because they shouldn&#8217;t be included in your webserver document root.</p>
<p>In the case of NoseRub, we will probably have a theme upload in the Admin area, which takes archives with two folders in it: <code>webroot</code> and <code>views</code></p>
<p><strong>Update: </strong> In the <a href="http://cakebakery.de/2009/07/06/themes-in-cakephp/">comments to the german version of this article</a>, Robert gives some advice on how to use view caching together with themes.</p>
<p>The translation: <em>Themes are not compatible with caching at the moment, as caching takes place in the Dispatcher, even before the controllers are created. If you know, which theme to use before dispatching the controller method, you can create your own Dispatcher class and overwrite cached(). If you need caching on views/elements, you need to create you own View class which extends the Theme class and implement renderElement() and/or element().</em></p>
]]></content:encoded>
			<wfw:commentRss>http://cakebakery.net/2009/07/06/how-to-use-themes-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why not to use query() and execute() &#8211; ever</title>
		<link>http://cakebakery.net/2009/07/06/why-not-to-use-query-and-execute-ever/</link>
		<comments>http://cakebakery.net/2009/07/06/why-not-to-use-query-and-execute-ever/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 10:00:47 +0000</pubDate>
		<dc:creator>Dirk Olbertz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cakebakery.net/?p=5</guid>
		<description><![CDATA[Using query() and execute() is very tempting: at some points you are faster doing a query in plain SQL, than building a proper find() statement.
But you really should not do it!
I had a lot of discussions with a colleague of mine and finally he made the argument that hit me:

beforeFind() and afterFind() will not apply [...]]]></description>
			<content:encoded><![CDATA[<p>Using <code>query()</code> and <code>execute()</code> is very tempting: at some points you are faster doing a query in plain SQL, than building a proper <code>find()</code> statement.</p>
<p><strong>But you really should not do it!</strong></p>
<p>I had a lot of discussions with a colleague of mine and finally he made the argument that hit me:</p>
<blockquote><p>
<code>beforeFind()</code> and <code>afterFind()</code> will not apply to your plain SQL statements.
</p></blockquote>
<p>That&#8217;s it. Life can be so simple.</p>
<p>Imagine you add some data in <code>afterFind()</code of your model and then just use a SQL statement to retrieve data from that model. Your code might break, because the additional data is not there.</p>
<p>And even if you now argument, that you will not do this, imagine the hassle you will be going through, if you have to use <code>beforeFind()</code> or <code>afterFind()</code>!</p>
<p>So, learn how to write proper <code>find()</code> statements and you will not only learn a lot from it, but you also will have more failproof code.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebakery.net/2009/07/06/why-not-to-use-query-and-execute-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to the Cake Bakery</title>
		<link>http://cakebakery.net/2009/07/06/welcome-to-the-cake-bakery/</link>
		<comments>http://cakebakery.net/2009/07/06/welcome-to-the-cake-bakery/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 09:53:16 +0000</pubDate>
		<dc:creator>Dirk Olbertz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cakebakery.net/?p=3</guid>
		<description><![CDATA[This is the english version of my older blog CakeBakery and will include recipes, tipps and tricks for your development with CakePHP.
I&#8217;m a CakePHP developer since 2006 and am currently using the web framework for NoseRub. NoseRub is an open, distributed social network and is released under the MIT license.
So, if you want to, you [...]]]></description>
			<content:encoded><![CDATA[<p>This is the english version of my older blog <a href="http://cakebakery.de">CakeBakery</a> and will include recipes, tipps and tricks for your development with CakePHP.</p>
<p>I&#8217;m a CakePHP developer since 2006 and am currently using the web framework for <a href="http://noserub.com">NoseRub</a>. NoseRub is an open, distributed social network and is released under the MIT license.</p>
<p>So, if you want to, you can check out the code: <a href="http://noserub.com/code">noserub.com/code</a></p>
<p>I hope to be able to add new content on a regular basis now. Often the small tricks are the most important ones, so I will not hesitate write about minor issues, too <img src='http://cakebakery.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cakebakery.net/2009/07/06/welcome-to-the-cake-bakery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
