Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My layout isn't loading in my Magento admin view

Tags:

magento

Here's my controller

<?php
class Desbest_Brands_Adminhtml_BrandController extends Mage_Adminhtml_Controller_action {
    public function indexAction() {
        //echo "showing 123 works!";
        $this->loadLayout(); $this->renderLayout();
    }

And here's my layout

<?xml version="1.0"?>
<layout version="1.0.0">
<brands_adminhtml_brand_index>
    <reference name="content">
        <block type="brands/adminhtml_brand" name="brand" />
        <block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>
    </reference>
</brands_adminhtml_brand_index>
</layout>

Yet nothing loads up when I show the view in my admin, not even the email subscribe form.

like image 617
desbest Avatar asked Dec 08 '22 22:12

desbest


1 Answers

If your action is called correctly (echo 123 shown), other than cache issue, there might be something's wrong with your handle.

In your action, try to put this code after $this->loadLayout() :

var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
die();

It will show all the handles loaded for that request.

The handle is generated from fullActionName, in simple way, we can say that it is generated as:

route + controller + action

Take a look at your config.xml.

If your config.xml like:

<admin>
    <routers>
        <brands>
            <use>admin</use>
            <args>
                <module>Desbest_Brands</module>
                <frontName>brands</frontName>
            </args>
        </brands>
    </routers>
</admin>

For your action, it will generate handle: <brands_adminhtml_brand_index>

If your config.xml like:

<admin>
    <routers>
        <brandsadmin>
            <use>admin</use>
            <args>
                <module>Desbest_Brands</module>
                <frontName>brands</frontName>
            </args>
        </brandsadmin>
    </routers>
</admin>

For your action, it will generate handle: <brandsadmin_adminhtml_brand_index>

Update:

And don't forget to define your admin layout in your config.xml, eg:

<adminhtml>
    <layout>
        <updates>
            <brandsadmin>
                <file>yourlayoutname.xml</file>
            </brandsadmin>
        </updates>
    </layout>
</adminhtml>

Put it under app/design/adminhtml/default/[default/youradmintheme]/layout/yourlayoutname.xml

like image 91
ivantedja Avatar answered Jan 09 '23 23:01

ivantedja