1
votes

I am having a difficult time getting the MVC structure set up for an admin module I am building for Magento. What I am hoping to do is correctly set up the design/adminhtml/layout/ppr_extension.xml to control the content of the page. So far I am loading the phtml and scripts from the IndexController :

$this->loadLayout();
$this->_setActiveMenu('ppr_menu/first_page');
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('ppr/ppr_1.phtml'));
$loadSimple = $this->getLayout()->getBlock('head')->addJs('ppr/load.simple.js');
$this->_addJs($loadSimple);
$this->renderLayout();

I want to load this from the config xml but for some reason I can not get this work. I imagine it has something to do with my package structure but I can not see it!

The template file exists in design/adminhtml/default/MyPackage/ppr_1.phtml

I tried adding this to the code/local/MyPackage/PPR/etc/config.xml

<adminhtml>
    <menu> ... </menu>

     <layout>
            <updates>
                <ppr_extension>
                    <file>ppr_extension.xml</file>
                </ppr_extension>
            </updates>
        </layout>
</adminhtml>

That extension xml is in design/adminhtml/default/default/layout/ppr_extension.xml

I tried many things in here like :

<?xml version="1.0"?>
<layout version="0.1.0">
    <ppr_adminhtml_ppr_index>       
     <reference name="head">
      <action method="addJs"><script>script.js</script></action>
    </reference>

No matter what I put in there nothing seems to happen. What am I missing?

I tried moving the extension.xml to design/adminhtml/MyPackage/layout but that didnt work either. Thanks for any help.. me brain hurts!

1
Start <a href="stackoverflow.com/questions/7048354/…> and come back when you have more information.Alan Storm
Thanks Alan, I tried the dump and I got }array(4) { [0]=> string(7) "default" [1]=> string(11) "STORE_admin" [2]=> string(30) "THEME_adminhtml_default_company" [3]=> string(24) "ppr_node_one_index_index" } bailing early at 22 in /home/magento/site/app/code/local/company/PPR/controllers/IndexController.php so I changed my handle to ppr_node_one_index_index but it still is not working. Thanks for any more help.Zac
Alan I just bought the commerce bug module.. but not really sure what I am looking for. Any hints on what I could post here to troubleshoot?Zac

1 Answers

4
votes

This should be easier now that you're using Commerce Bug.

The first step to debugging a layout problem is to make sure that your layout xml file is being loaded. Go to the layout tab in Commerce Bug and click on the Package Layout link. Look for your custom XML there. If you don't see it that means your XML isn't being loaded, and you should concentrate on getting the right XML in your config.xml, and getting your file in the right location.

Also, consider that the there's no need to use layout xml at all. The Admin Console developers use it for the outer shell and for some of the magic widget features, but there's a lot of stuff in the admin that's just blocks added in controller actions, or blocks added in other blocks. There's no shame in using PHP to generate your block objects.