Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento layout XML not instantiating blocks
    text
    copied!<p>I've mucked around a bit with this and I've tried all kinds of different values from various sites and a couple e-books on the subject. The total lack of any semblance of consistency has made this more difficult than I feel it should be.</p> <p>Basically I cannot get it to use <code>content.phtml</code> to override the <code>content</code> section in the main template. I have done it by forcing it through the controller like so:</p> <pre><code>$content = $this-&gt;getLayout()-&gt;createBlock(...); $this-&gt;getLayout()-&gt;getBlock('content')-&gt;append($content); </code></pre> <p>But I feel this makes my module inflexible, and makes parts of the configuration redundant and misleading.</p> <p>I am using a block called <code>Company_AdvSearch_Block_Results</code> which extends <code>Mage_Core_Block_Template</code>.</p> <p><strong>File: config.xml</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;config&gt; &lt;modules&gt; &lt;Company_AdvSearch&gt; &lt;version&gt;0.1.0&lt;/version&gt; &lt;/Company_AdvSearch&gt; &lt;/modules&gt; &lt;frontend&gt; &lt;routers&gt; &lt;advsearch&gt; &lt;use&gt;standard&lt;/use&gt; &lt;args&gt; &lt;module&gt;Company_AdvSearch&lt;/module&gt; &lt;frontName&gt;advsearch&lt;/frontName&gt; &lt;/args&gt; &lt;/advsearch&gt; &lt;/routers&gt; &lt;layout&gt; &lt;updates&gt; &lt;advsearch module="Company_AdvSearch"&gt; &lt;file&gt;advsearch.xml&lt;/file&gt; &lt;/advsearch&gt; &lt;/updates&gt; &lt;/layout&gt; &lt;/frontend&gt; &lt;global&gt; &lt;blocks&gt; &lt;advsearch&gt; &lt;class&gt;Company_AdvSearch_Block&lt;/class&gt; &lt;/advsearch&gt; &lt;/blocks&gt; &lt;/global&gt; &lt;/config&gt; </code></pre> <p><strong>File: advsearch.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;layout version="0.1.0"&gt; &lt;advsearch_index_index&gt; &lt;reference name="head"&gt; &lt;action method="setTitle"&gt; &lt;title&gt;Advanced Search&lt;/title&gt; &lt;/action&gt; &lt;/reference&gt; &lt;reference name="root"&gt; &lt;action method="setTemplate"&gt; &lt;template&gt;page/2columns-left.phtml&lt;/template&gt; &lt;/action&gt; &lt;/reference&gt; &lt;reference name="content"&gt; &lt;block type="advsearch/results" name="advsearch" template="advsearch/content.phtml"/&gt; &lt;/reference&gt; &lt;/advsearch_index_index&gt; &lt;/layout&gt; </code></pre> <p>So:</p> <ol> <li>How would I get it to actually update the <code>content</code> section of the layout?</li> <li>How would I update other parts (i.e. <code>left</code>) using my module so they can access the same data?</li> </ol> <p><strong>Update</strong></p> <p>I've run into yet another issue. After inserting this block, the referenced components successfully disappeared.</p> <pre><code>&lt;reference name="left"&gt; &lt;remove name="catalog.compare.sidebar"/&gt; &lt;remove name="left.reports.product.viewed"/&gt; &lt;remove name="catalog.product.related"/&gt; &lt;/reference&gt; </code></pre> <p>Now, after commenting this block and even deleting the file from the server, I can't get those parts to come back on this page. It seems to be disregarding the XML file entirely (both normal caching and compiler caching are disabled).</p>
 

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