title: How to modify $content_for_layout in CakePHP 1.3
body: <p>I am using CakePHP 1.3. In <code>app/views/layouts/default.ctp</code> I am using this:</p>
  
  <pre><code>&lt;?php echo $content_for_layout;?&gt;
  </code></pre>
  
  <p>According to CakePHP Application Development, by Ahsanul Bari and Anupom Syam, </p>
  
  <blockquote>
    <p>"This line is mainly responsible for placing controller-rendered view
    contents inside the layout. We must include this to tell Cake where to
    place the action-specific controller-rendered views."</p>
  </blockquote>
  
  <p>I was trying to figure out how to modify the content of <code>$content_for_layout</code>. But I guess that is not the kind of variable that I am supposed to modify to modify the layout. What I am trying to accomplish is to either modify <code>$content_for_layout</code> or create a new layout to customize some elements for an A/B testing experiment. Could you help me to better understand how to manipulate <code>$content_for_layout</code>? Thank you.</p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>I am configuring an A/B testing experiment. I have this in <code>app/views/layouts/default.ctp</code>:</p>
  
  <pre><code>&lt;body&gt;
      ..........
      &lt;div id="split-test-homepage-content-original"&gt;
          ..........
          &lt;?php echo $content_for_layout;?&gt;
          ..........
      &lt;/div&gt;
      &lt;div id="split-test-homepage-content-redesign"&gt;
          ..........
          &lt;?php echo $content_for_layout;?&gt;
          ..........
      &lt;/div/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>With CSS I am hiding/showing either <code>split-test-homepage-content-original</code> or <code>split-test-homepage-content-redesign</code> depending on the version that the split test will show. But I am having problems because <code>$content_for_layout</code> is being rendered twice. Even though visually people only see one version but behind the scenes the page has <code>$content_for_layout</code> loading twice on the same page. This is causing all kinds of problems to me such as duplicate forms, JavaScript elements not working correctly as a result of duplicate variables, etc. What I want to do is to modify what <code>$content_for_layout</code> does for <code>&lt;div id="split-test-homepage-content-redesign"&gt;</code>. One option I am considering is to use JavaScript so that in the <code>jQuery(document).ready(function($) {</code> section I can do something in the experiment so that if a variable contains a specific boolean value, I show one version or the other. Something like this:</p>
  
  <p><code>if(javascriptvariable==true){</code> then use the following HTML for the view:</p>
  
  <pre><code>&lt;div id="split-test-homepage-content-original"&gt;
      ..........
      &lt;?php echo $content_for_layout;?&gt;
      ..........
  &lt;/div&gt;
  </code></pre>
  
  <p>else, the Javascript will take care of not displaying the above, but this:</p>
  
  <pre><code>&lt;div id="split-test-homepage-content-redesign"&gt;
      ..........
      &lt;?php echo $content_for_layout;?&gt;
      ..........
  &lt;/div/&gt;
  </code></pre>
  
  <p>Does the JavaScript approach make sense to you or should I do something about creating new layouts or modifying what <code>$content_for_layout</code> does? Thank you.</p>