1

I've gone through about 50 different pages and posts of people having the same issue, but none seem to be caused by what ever is casing my issue.

I've got my module, registered the route and it's loading the layout XML all fine as the page template is the correct one. I can also log in my controller and action just fine. If I change my block type to a built in Magento type like core/template It gives me an error caused by the code in my template phtml file so the template file is working. It just seems to be the block type throwing me off.

I keep looking through tutorials and guides but I'm failing to see any difference sin my approach. I see not many people putting their block in a sub folder in the Blocks folder, but I am calling the block with lookbook_view. I also tested by moving the view block out of m Lookbook folder and placing it directly in the Block folder (and renaming the class) but this also did not work

app/design/frontend/base/default/layout/lookbook.xml

<lookbook_lookbook_view translate="label">
    <label>Single Lookbook Page</label>
    <remove name="right"/>
    <remove name="left"/>

    <reference name="root">
        <action method="setTemplate">
            <template>page/1column.phtml</template>
        </action>
    </reference>
    <reference name="content">
        <block type="lookbook/lookbook_view" name="lookbook_view" template="lookbook/view.phtml"/>
    </reference>
</lookbook_lookbook_view>

app/code/local/Test/Lookbook/etc/config.xml

<config>
    <global>
        <blocks>
            <lookbook>
                <class>Test_Lookbook_Block</class>
            </lookbook>
        </blocks>
    ....
</config>
...
<frontend>
    <routers>
        <lookbook>
            <use>standard</use>
            <args>
                <module>Test_Lookbook</module>
                <frontName>lookbook</frontName>
            </args>
        </lookbook>
    </routers>
    <layout>
        <updates>
            <lookbook>
                <file>lookbook.xml</file>
            </lookbook>
        </updates>
    </layout>
</frontend>

app/code/local/Test/Lookbook/Block/Lookbook/view.php

class Test_Lookbook_Block_Lookbook_View extends Mage_Core_Block_Template{

   public function getCurrentLookbook()
   {
       echo 'test';die();

       return Mage::registry('current_lookbook');
   }
}
  • 2
    When you have your block set up correctly you can validate it in the template by doing <?php echo get_class($this);?> and it will tell you what block it thinks it is. Just to validate that it's actually getting your instance of Test_Lookbook_Block_Lookbook_View. Also putting subdirectories in /Block is grand, no worries :) – Luke Rodgers Aug 14 '15 at 11:33
  • But my issue is my template view.php file doesn't get called when i use the correct block type. – Chris Morris Aug 14 '15 at 15:20
2

After unknown hours and google searches.

view.php needed to be View.php Magento capitalizes the files it looks for in the block type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.