Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A layout object is a collection of block objects. The blocks are organized in parent/child tree form.</p> <p>Your layout has a single block. You have not added any child blocks to it. Therefore, when your block's template tries to render a child with getChildHtml, it can't find one, and no additional output is produced. </p> <p>Additionally, the topLinks block, by default, doesn't render anything. It needs to have links added to it. This is typically done through other layout.xml files.</p> <p>Finally, it's probably better to kick off rendering with a call to </p> <pre><code>echo $block_header-&gt;toHtml(); </code></pre> <p>Below is an example of how you can nest blocks correctly, as well as call their action methods, such that you'll be able to render your blocks outside of the normal dispatching procedure. It's different from yours in that we create a new link block, add a link to it, and add it to your top level block.</p> <pre><code>require_once 'app/Mage.php'; umask(0); Mage::app('default'); $layout = Mage::getSingleton('core/layout'); $block_header = $layout-&gt;createBlock('page/html_header')-&gt;setTemplate('page/html/header.phtml'); // &lt;block type="" name="top.links" as="topLinks"/&gt; $block_links = $layout-&gt;createBlock('page/template_links','top.links')-&gt;setTemplate('page/template/links.phtml'); $block_header-&gt;setChild('topLinks',$block_links); //&lt;reference name="top.links"&gt; // &lt;action method="addLink" translate="label title" module="customer"&gt;&lt;label&gt;My Account&lt;/label&gt;&lt;url helper="customer/getAccountUrl"/&gt;&lt;title&gt;My Account&lt;/title&gt;&lt;prepare/&gt;&lt;urlParams/&gt;&lt;position&gt;10&lt;/position&gt;&lt;/action&gt; //&lt;/reference&gt; $block_links-&gt;addLink('My Account','foo/baz/bar/','My Account','','',10); echo $block_header-&gt;toHtml(); </code></pre>
 

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