<?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; layout</title>
	<atom:link href="http://cakebaker.42dh.com/tags/layout/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>How to get rid of &#8220;CakePHP: the PHP Rapid Development Framework&#8221; at the top of your pages</title>
		<link>http://cakebaker.42dh.com/2007/05/30/how-to-get-rid-of-cakephp-the-php-rapid-development-framework-at-the-top-of-your-pages/</link>
		<comments>http://cakebaker.42dh.com/2007/05/30/how-to-get-rid-of-cakephp-the-php-rapid-development-framework-at-the-top-of-your-pages/#comments</comments>
		<pubDate>Wed, 30 May 2007 09:02:19 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/30/how-to-get-rid-of-cakephp-the-php-rapid-development-framework-at-the-top-of-your-pages/</guid>
		<description><![CDATA[An often asked newbie question in the IRC channel is: How can I get rid of &#8220;CakePHP: the PHP Rapid Development Framework&#8221; at the top of my pages? This header is shown because you don&#8217;t have defined your own layout yet, and so the default layout is used which comes with CakePHP (located in /cake/libs/view/layouts/default.ctp [...]]]></description>
			<content:encoded><![CDATA[<p>An often asked newbie question in the IRC channel is: How can I get rid of &#8220;CakePHP: the PHP Rapid Development Framework&#8221; at the top of my pages? </p>
<p>This header is shown because you don&#8217;t have defined your own layout yet, and so the default layout is used which comes with CakePHP (located in /cake/libs/view/layouts/default.ctp <del datetime="2009-05-29T14:37:43+00:00">/cake/libs/view/templates/layouts/default.ctp (respectively .thtml with CakePHP 1.1)</del>). Now the first idea is to edit this file. That would work. But it violates the golden rule of CakePHP: <strong>Don&#8217;t edit files in the cake folder!</strong> So, instead you have to copy the file to /app/views/layouts. Then you can edit the layout in any way you want.</p>
<p>Happy baking :)</p>
<p>Update 2009-05-29: Fixed path to layout because it has changed since this article has been written. Thanks to Göran K. for the hint!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/05/30/how-to-get-rid-of-cakephp-the-php-rapid-development-framework-at-the-top-of-your-pages/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Define your own &#8220;for_layout&#8221; variables</title>
		<link>http://cakebaker.42dh.com/2007/04/28/define-your-own-for_layout-variables/</link>
		<comments>http://cakebaker.42dh.com/2007/04/28/define-your-own-for_layout-variables/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 13:50:00 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/04/28/define-your-own-for_layout-variables/</guid>
		<description><![CDATA[CakePHP comes with three &#8220;for_layout&#8221; variables: $title_for_layout, $content_for_layout, and $scripts_for_layout (since 1.2). As the names imply, those variables are used within the layout as &#8220;placeholders&#8221; for some data. The simplest way to use your own &#8220;for_layout&#8221; variable is to set a variable in your controller or view: $this-&#62;set('var_for_layout', 'value'); You can then use this variable [...]]]></description>
			<content:encoded><![CDATA[<p>CakePHP comes with three &#8220;for_layout&#8221; variables: $title_for_layout, $content_for_layout, and $scripts_for_layout (since 1.2). As the names imply, those variables are used within the layout as &#8220;placeholders&#8221; for some data. </p>
<p>The simplest way to use your own &#8220;for_layout&#8221; variable is to set a variable in your controller or view:</p>
<pre>
$this-&gt;set('var_for_layout', 'value');
</pre>
<p>You can then use this variable in your layout with:</p>
<pre>
if (isset($var_for_layout)) {
     echo $var_for_layout;
}
</pre>
<p>The &#8220;problem&#8221; of this solution is that you need an isset() check to avoid an &#8220;undefined variable&#8221; error when the variable is not set. This check is not necessary for the built-in &#8220;for_layout&#8221; variables, and so it doesn&#8217;t look very consistent if you mix those variables with your own &#8220;for_layout&#8221; variables. </p>
<p>To avoid this problem I wrote a simple helper, which automatically sets an empty string if the variable is not set.</p>
<pre>
class DemoHelper extends AppHelper {
    var $value = '';

    function afterRender() {
        $view = ClassRegistry::getObject('view');
        $view-&gt;set('var_for_layout', $this-&gt;value);
    }

    function setValue($value) {
        $this-&gt;value = $value;
    }
}
</pre>
<p>This helper is then included in the $helpers array of my AppController (app/app_controller.php):</p>
<pre>
var $helpers = array('Demo');
</pre>
<p>With that I can access the helper in all my views. To set the value for the $var_for_layout variable I have to use the helper instead of $this-&gt;set():</p>
<pre>
$demo->setValue('value');
</pre>
<p>In my layout I can now simply output my &#8220;for_layout&#8221; variable:</p>
<pre>
echo $var_for_layout;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/04/28/define-your-own-for_layout-variables/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

