Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Ben said, I don't know why you're going to put it on the observer but the problem in your case is the sequence of <code>loadLayout</code>.</p> <p>You can check your loaded layout xml by using:</p> <p><code>Mage::log(Mage::getSingleton('core/layout')-&gt;getUpdate()-&gt;asString());</code></p> <p>Pretty sure your <code>&lt;action method="setTemplate"&gt;&lt;template&gt;customelayout/product/view.phtml&lt;/template&gt;</code> has been overridden by other <code>setTemplate</code> that's the reason your template is not shown.</p> <pre><code>Mage_Core_Controller_Varien_Action public function loadLayout($handles=null, $generateBlocks=true, $generateXml=true) { // if handles were specified in arguments load them first if (false!==$handles &amp;&amp; ''!==$handles) { $this-&gt;getLayout()-&gt;getUpdate()-&gt;addHandle($handles ? $handles : 'default'); } // add default layout handles for this action $this-&gt;addActionLayoutHandles(); $this-&gt;loadLayoutUpdates(); //in here: $this-&gt;getLayout()-&gt;getUpdate()-&gt;load(); if (!$generateXml) { return $this; } //event: controller_action_layout_generate_xml_before $this-&gt;generateLayoutXml(); //in here: $this-&gt;getLayout()-&gt;generateXml(); if (!$generateBlocks) { return $this; } //event: controller_action_layout_generate_blocks_before, your observer is located here $this-&gt;generateLayoutBlocks(); //in here: $this-&gt;getLayout()-&gt;generateBlocks(); $this-&gt;_isLayoutLoaded = true; return $this; } </code></pre> <p>So, you're going to modify the xml using event: <code>controller_action_layout_generate_blocks_before</code>.</p> <p>It means what you need to do is:</p> <pre><code>//add the update $layout-&gt;getUpdate()-&gt;addUpdate('&lt;reference name="product.info"&gt;&lt;action method="setTemplate"&gt;&lt;template&gt;customelayout/product/view.phtml&lt;/template&gt;&lt;/action&gt;&lt;/reference&gt;'); //then generate the xml $layout-&gt;generateXml(); </code></pre> <p>What cause your problem is:</p> <p><code>$layout-&gt;getUpdate()-&gt;load();</code></p> <p>was called again after</p> <pre><code>$layout-&gt;getUpdate()-&gt;addUpdate('&lt;reference name="product.info"&gt;&lt;action method="setTemplate"&gt;&lt;template&gt;customelayout/product/view.phtml&lt;/template&gt;&lt;/action&gt;&lt;/reference&gt;'); </code></pre> <p>Though it is better to use event: <code>controller_action_layout_generate_xml_before</code>. So that you don't need to generate your xml twice.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload