1

I have a custom module with the following:

magento-project/app/code/local/Hunique/Customs/etc/config.xml

<?xml version="1.0" ?>
 <config>
<modules>
    <Hunique_Customs>
        <version>1.0.1</version>
    </Hunique_Customs>
</modules>

<global>
    <models>
        <custommodule>
            <class>Hunique_Customs_Model</class>
            <resourceModel>custommodule_resource</resourceModel>
        </custommodule>
        <custommodule_resource>
            <class>Hunique_Customs_Model_Resource</class>
            <entities>
                <custommodule>
                    <table>custommodule</table>
                </custommodule>
                <questions>
                    <table>questions</table>
                </questions>
                <answers>
                    <table>answers</table>
                </answers>
            </entities>
        </custommodule_resource>
    </models>

    <resources>
        <custommodule_setup>
            <setup>
                <module>Hunique_Customs</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </custommodule_setup>
        <custommodule_read>
            <connection>
                <use>core_read</use>
            </connection>
        </custommodule_read>
        <custommodule_write>
            <connection>
                <use>core_write</use>
            </connection>
        </custommodule_write>
    </resources>

    <blocks>
        <custommodule>
            <class>Hunique_Customs_Block</class>
        </custommodule>
    </blocks>

    <helpers>
        <hunique_customs>
            <class>Hunique_Customs_Helper</class>
        </hunique_customs>
    </helpers>

</global>

<frontend>
    <routers>
        <custommodule>
            <use>standard</use>
            <args>
                <module>Hunique_Customs</module>
                <frontName>custommodule</frontName>
            </args>
        </custommodule>
    </routers>

    <layout>
        <updates>
            <custommodule>
                <file>custommodule.xml</file>
            </custommodule>
        </updates>
    </layout>

</frontend>    
<admin>
    <routers>
        <adminhtml>
            <use>admin</use>
            <args>
                <modules>
                    <Hunique_Customs before="Mage_Adminhtml">Hunique_Customs</Hunique_Customs>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

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

Then I have the /magento-project/app/code/local/Hunique/Customs/etc/adminhtml.xml in the same folder

<config>
<menu>
    <hunique>
        <title>Hunique</title>
        <sort_order>1</sort_order>
        <children>
            <customs_qa module="hunique_customs">
                <title>Questions And Answers</title>
                <sort_order>1</sort_order>
                <action>adminhtml/custommodule</action>
            </customs_qa>
        </children>
    </hunique>
</menu>

Then in the desing i have: /magento-project/app/design/adminhtml/default/default/layout/custommodule.xml

<?xml version="1.0"?>
<layout>
  <adminhtml_custommodule_index>
    <reference name="content">
        <block type="core/template" output="toHtml" name="templateBlock" template="custommodule/questions-and-answers.phtml" />
    </reference>
   </adminhtml_custommodule_index>
 </layout>

and I have the file /magento- project/app/design/adminhtml/default/default/templates/custommodule/questions-and-answers.phtml but that just contains an h1 tag with TEST in it now.

I also have the controller: /magento-project/app/code/local/Hunique/Customs/controllers/CustommoduleController.php

<?php
class Hunique_Customs_CustommoduleController extends Mage_Adminhtml_Controller_Action
{   
  public function indexAction()
  {    
    var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    $this->loadLayout();
    $this->renderLayout();
  }
}

I have the var dump to see if i had any handles but that is an empty array. My page loads from the admin menu..enter image description here My routes and admin menu work fine, i just can't get my phtml to show up... anyone that can point me in the right direction?

1 Answer 1

2

The code you provided should work as it is. Although both your config.xml and adminhtml.xml files don't have their <config> tags closed, I suspect you just made this mistake when pasting code here, because otherwise you'd see an error instead of a page with empty content area.

My advice is that you should search for typos in file names or wrong directories nesting. Also, your var_dump is empty, because you try to show layout handles before actually loading the layout. You have to switch the first two lines in your action:

public function indexAction() {  
    $this->loadLayout();
    var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    $this->renderLayout();
}

Also, you can also make sure that your admin panel uses the default/default package/theme or that it's in the fallback chain. If it's using some other package (e.g. custompackage/default), it won't look in default/default. If you're not sure, you can always place your layout update xml and your template in base/default instead. It doesn't exist in the admin panel, but you can create it and it will be used as the last fallback.

Let me know if it helps.

2
  • alright that helps. Not sure why my code breaks, but yes my handles show up, so that is good. My page is still empty, but i appreciate the confirmation my code looks fine, oh and yes copy paste issue with closing config tags. Where is the "package" set for the admin though? Commented Jun 1, 2015 at 13:08
  • 1
    You may want to check the accepted answer to this question: magento.stackexchange.com/questions/14111/… Also, to make sure your layout update xml is seen by the system, you can add <remove name="head" /> inside the <adminhtml_custommodule_index>. It will remove the entire head (along with all the styles, JS files etc.), so if you see an unstyled page, you know that your layout update file is ok. Commented Jun 1, 2015 at 13:45

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.