3

I'm trying to load in a block on one of my admin pages in a custom module, but it doesn't appear to be loading. At first I thought it was a handle issue, but I've found out that the handle is adminhtml_bar_index through the controller. I know it's not loading because I have debug mode on, and, when I break the XML, no error whatsoever gets thrown or logged. What else could be wrong?

/app/code/local/Foo/Bar/etc/config.xml

<?xml version="1.0"?>
<config>
<!-- ... -->
    <adminhtml>
        <layout>
            <updates>
                <bar>
                    <file>foo_bar.xml</file>
                </bar>
            </updates>
        </layout>
    <!-- ... -->
    </adminhtml>
<!-- ... -->
</config> 

/app/design/adminhtml/default/default/layout/foo_bar.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_bar_index>
        <reference name="content">
            <block type="foo_bar/adminhtml_profiles_grid" />
        <reference>
    </adminhtml_bar_index>
</layout>

Thanks in advance!

Edit: I've managed to make it load. I don't know how, but I did. I think it was a handle issue still.

3 Answers 3

3

Here are some sanity checks for when, like now, there are no error messages to go on.

  • Are all files readable by the web server/PHP?
    I have a quick publishing script which recursively forces some file permissions. The only argument it needs is the folder to check.

    #!/bin/bash
    
    chown -R :http $* 2>/dev/null
    chmod -R g+rw $* 2>/dev/null
    find $* -type d -exec chmod g+x {} \; 2>/dev/null
    
  • Is the module definitely loaded?
    At the very least it should be listed in System > Configuration > Advanced > Disable Modules Output. For a more thorough debugging see Alan Storm's Module List Module.

  • Disable all caching whenever developing.
    If the old config.xml content is being used then Magento cannot be aware of new instructions to load layout files. Ditto for changes to cached layouts.

  • For the handle adminhtml_bar_index the responsible action is probably in the file app/code/local/Foo/Bar/controllers/BarController.php and looks like this:

    class Foo_Bar_BarController extends Mage_Core_Controller_Front_Action {
        public function indexAction() {
            $this->loadLayout();
            $this->renderLayout();
        }
    }
    

    To check execution is getting this far put a die(__METHOD__) call in that function and refresh the page. Seeing the method name is definitive proof.

  • In your config.xml you correctly have this:

        <adminhtml>
            <layout>
                <updates>
                    <bar>
                        <file>foo_bar.xml</file>
                    </bar>
                </updates>
            </layout>
        </adminhtml>
    

    Think what would happen if <bar> was also used by another module? One of the two modules would have it's contribution overruled. Try changing the name of that node to anything else.

6
  • Thanks for your response. The only thing that I didn't check was the file permissions, but even with this, it doesn't work. Do you have any other suggestions? I have no idea where to look anymore.
    – Thierry
    Commented Sep 10, 2014 at 8:42
  • I'm running out of ideas but I did notice one more thing, the block you specify is a foo_bar/adminhtml_profiles_grid. Typically for grid pages the container is specified instead and the child grid block is loaded automatically from the _blockGroup and _controller names. See this tutorial for details. Commented Sep 10, 2014 at 10:13
  • I've changed it, but to no avail. The layout file doesn't appear to be loaded in in the first place, after all.
    – Thierry
    Commented Sep 10, 2014 at 12:21
  • It was a long shot... Commented Sep 10, 2014 at 12:22
  • Is there absolutely no way to produce an error message?
    – Thierry
    Commented Sep 10, 2014 at 12:26
0

Your config file is attempting to load foo_bar.xml but you called the layout file bar.xml. One of those will have to change.

1
  • I'm sorry, that's a typo.
    – Thierry
    Commented Sep 9, 2014 at 15:24
0

If your controller is at /app/code/local/Foo/Bar/controllers/Adminhtml/IndexController.php

Please replace your content of

/app/design/adminhtml/default/default/layout/foo_bar.xml

with following

<?xml version="1.0"?>
<layout>
    <bar_adminhtml_index_index>
        <reference name="content">
            <block type="foo_bar/adminhtml_profiles_grid" />
        <reference>
    </bar_adminhtml_index_index>
</layout> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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