Magento 1.9 – Block Template Not Rendering

blocksmagento-1.9template

I'm using Magento 1.9.1.1 with the latest patches on PHP 5.6.

I am attempting to add a dynamic link to the top.links nav on the frontend. I have managed to get to the point where my block seems to be loaded, but I do not see anything from my template. Here are the relevant files:

app/design/frontend/callcenter/default/layout/local.xml

<?xml version="1.0" ?>
<layout>
    <default>
        <reference name="top.links">
            <block type="callcenter_frontadmin/adminaccount" name="adminaccount" template="frontadmin/adminaccount.phtml" />
        </reference>
        <remove name="left.permanent.callout"/>
        <remove name="right.permanent.callout"/>
    </default>
</layout>

app/design/frontend/callcenter/default/template/frontadmin/adminaccount.phtml

Hello, world!

My block is located in app/code/local/Callcenter/Frontadmin/Block/Adminaccount.php and is in fact being loaded (if I die() inside it, the site dies). If I substitute the <block> tag for something else, like an <action method="addLink" whatever I add seems to appear in the correct place.

Caching is turned off. Logging does not reveal anything suspicious in the logfiles.

EDIT: Here is my block

app/code/local/Callcenter/Frontadmin/Block/Adminaccount.php

<?php

class Callcenter_Frontadmin_Block_Adminaccount extends Mage_Core_Block_Template {

}

Best Answer

the top.links block is an instance of a template block. As such it doesn't automatically render child blocks. To render your block as a child of top.links you will have to edit the page/template/links.phtmltemplate within your theme and add an explicit render like this:

echo $this->getChildHtml('adminaccount');

...

gonna correct myself slightly, you should also be able to do this:

    <reference name="top.links">
        <action method="addLinkBlock"><blockName>adminaccount</blockName></action>
    </reference>

within your existing default node

Related Topic