Strawberry
Strawberry

Reputation: 67888

Why is my block not showing?

I don't know why my block isn't showing up. It's not showing up on any page, and I cleared the cache. Can someone help me figure out what I missed? However, the var_dump('test') shows up!

app/design/frontend/default/default/template/justin/head.phtml

testing this block

Justin/Bieber/Block/Sings.php

class Justin_Bieber_Block_Sings extends Mage_Core_Block_Template
{
    protected function _construct()
    {
        parent::_construct();
        var_dump("test");
    }
}   

config.xml

<frontend>
       ...
    <layout>
        <updates>
            <bieber>
                <file>justin.xml</file>
            </bieber>
        </updates>
    </layout>
</frontend>
<global>
    <blocks>
        <bieber>
            <class>Justin_Bieber_Block</class>
        </bieber>
    </blocks>
    ...
</global>

app/design/frontend/default/default/layout/justin.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <block type="bieber/bieber" name="justin_bieber">
                 <action method="setTemplate">
                    <template>justin/head.phtml</template>
                </action>
            </block>
        </reference>
    </default>
</layout>

Upvotes: 3

Views: 4069

Answers (3)

Strawberry
Strawberry

Reputation: 67888

Symlinks were the problem. Magento won't be able to grab the file if it is in a symlinked directory.

Turn it on! Magento/Zend not allowing symbolic links

Another thing is to turn on template hints!

Upvotes: 1

MagePsycho
MagePsycho

Reputation: 2004


Your code seems fine to me.
Regarding justin.xml try to change it to the following:

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <block type="bieber/sings" name="justin_bieber" as="justin_bieber" template="justin/head.phtml" /> 
        </reference>
    </default>
</layout>

Let me know if that works!

Upvotes: 1

blakcaps
blakcaps

Reputation: 2647

In your justin.xml block type should be

 <block type="bieber/sings" name="justin_bieber">

In this case "bieber" is your module alias name and "sings" is class name.

Upvotes: 1

Related Questions