S
S
stdio962016-07-06 13:46:47
Magento
stdio96, 2016-07-06 13:46:47

How to add a block on the module page in magento (in adminhtml)?

Hello. There is a standard module in magento.
e070a059350b42ce9903b7539e33a876.png
It is necessary (without rewriting standard files) to add a block to the page. Block like this.
8d08c429e0bd479d9c19b2714e5fa156.png
The custom module has already been created. Should I create a phtml template? Or it is possible to rewrite simply by means of config.xml?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dante_FX, 2016-07-07
@Dante_FX

Whether you need it or not - you decide now yourself)
Notes:
1) Magento 1.7.2.0.
2) The method, as they say, "for myself" - I would finish it in a commercial module.
3) You are familiar with magenta. If something is not clear - clarify.
Let's go:
1) If there was no layout for the admin in the module before, connect it in config.xml
2) Add to the layout:

<adminhtml_sales_order_view>        
        <reference name="order_tab_info">
            <block type="dante_test/adminhtml_test" name="dante_test_test" template="dante/test/test.phtml" />            
        </reference>       
    </adminhtml_sales_order_view>

This is how you add your child block to the layout of the block responsible for displaying the contents of the "Information" tab.
Our child block is app/code/{local/community}/Dante/Test/Block/Adminhtml/Test.php
with template \app\design\adminhtml\default\default\template\dante\test\test.phtml
This block should now be rendered.
Method 1)
To do this, either do a rewrite of the Mage_Adminhtml_Block_Sales_Order_View_Tab_Info class in the config.
Now we have a class:
class Dante_Test_Block_Adminhtml_Sales_Order_View_Tab_Info  extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Info {
    public function getTestHtml()
    {
        return $this->getChildHtml('dante_test_test');
    }
    
    protected function _toHtml()
    {
        return parent::_toHtml() . $this->getTestHtml();
    }
}

where
Displays the content of the module template
dante/test/test.phtml
Thus, the Your block will be added to the very bottom. To put it in the middle - either use js, or
reassign your phtml template to the Dante_Test_Block_Adminhtml_Sales_Order_View_Tab_Info block, where copy the original magenta template (\app\design\adminhtml\default\default\template\sales\order\view\tab\info.phtml) and enter necessary edits to it.
Method 2 is that you do not rewrite the Mage_Adminhtml_Block_Sales_Order_View_Tab_Info class, but copy it from the core to the local directory (with the paths preserved) and change it as you wish. The original file in the core directory remains unchanged and will no longer be used.
PS If for some reason you are not satisfied with the rewrite (this may be due to a conflict with rewrites of third-party modules) or the transfer to the local directory (which may cause a problem after updating magenta - although this seems to be an unlikely scenario now), you You can complete the task through the use of an observer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question