0
votes

app\code\local\Stw\Tree\Block\Adminhtml\Adminblock.php

<?php


class Stw_Tree_Block_Adminhtml_Adminblock extends Mage_Adminhtml_Block_Template
{
    public function __construct()
    {
        parent::__construct();

    }

    protected function _prepareLayout()
    {
        return parent::_prepareLayout();
    }

    public function getHandleUpdates()
    {
        Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
    }

}

app\code\local\Stw\Tree\controllers\Adminhtml\CustomController.php

class Stw_Tree_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->_setActiveMenu('mycustomtab');
        $this->renderLayout();

    }

}

app\design\adminhtml\default\default\layout\tree.xml

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="content">
            <block type="tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
        </reference>
    </default>
</layout>

app\code\local\Stw\Tree\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Stw_Tree>
            <version>1.0.0</version>
        </Stw_Tree>
    </modules>
    <global>
        <helpers>
            <stw_tree>
                <!-- Helper definition needed by Magento -->
                <class>Mage_Core_Helper</class>
            </stw_tree>
        </helpers>
        <blocks>
            <stw_tree>
                <class>Stw_Tree_Block</class>
            </stw_tree>
        </blocks>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <stw_tree before="Mage_Adminhtml">Stw_Tree_Adminhtml</stw_tree>
                    </modules>
                </args>
                <layout>
                    <updates>
                        <tree>
                            <file>tree.xml</file>
                        </tree>
                    </updates>
                </layout>
            </adminhtml>
        </routers>
    </admin>
</config>

I want load myform.phtml in admin section of magento, but nothing is loading. I am not understanding what is wrong in that. please someone tell me changes. myform.phtml contains pure HTML code

2

2 Answers

1
votes

As defined block in config.xml as below :-

<blocks>
    <stw_tree>
        <class>Stw_Tree_Block</class>
    </stw_tree>
 </blocks>

You need to use same alias to call this block from Layout as below :-

<layout>
    <default>
        <reference name="content">
            <block type="stw_tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
        </reference>
    </default>
</layout>
0
votes

I don't believe the layout node should be inside the router note like that in your config.xml file. You should add a new adminhtml node as a sibling to admin, i.e. a direct child of config.

    </admin>
    <adminhtml>
      <layout>
            <updates>
                <tree>
                    <file>tree.xml</file>
                </tree>
            </updates>
        </layout>
    </adminhtml>
</config>