I would like to add a button to the admin interface for a module to perform some custom actions, at the moment the observer isn't being picked up once the admin interface loads.
here is my config.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Ds_Imports>
<version>1.0.0</version>
</Ds_Imports>
</modules>
<global>
<adminhtml>
<events>
<adminhtml_widget_container_html_before>
<observers>
<add_button_test>
<type>singleton</type>
<class>Ds_Imports_Model_Observer</class>
<method>addButtonTest</method>
</add_button_test>
</observers>
</adminhtml_widget_container_html_before>
</events>
<layout>
<updates>
<ds_imports>
<file>importer.xml</file>
</ds_imports>
</updates>
</layout>
</adminhtml>
<helpers>
<imports>
<class>Ds_Imports_Helper</class>
</imports>
</helpers>
<blocks>
<imports>
<class>Ds_Imports_Block</class>
</imports>
<!-- <adminhtml>
<rewrite>
<sales_order_grid>Ds_Imports_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml> -->
</blocks>
<models>
<imports>
<class>Ds_Imports_Model</class>
<resourceModel>imports_resource</resourceModel>
</imports>
</models>
<resources>
<imports_setup>
<setup>
<module>Ds_Imports</module>
</setup>
</imports_setup>
</resources>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<ds_imports before="Mage_Adminhtml">Ds_Imports_Adminhtml</ds_imports>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
and this is the observer it is trying to load
<?php
class Ds_Imports_Model_Observer extends Varien_Event_Observer
{
public function __construct() {
}
public function addButtonTest($observer) {
echo "test";
die();
$container = $observer->getBlock();
if(null !== $container && $container->getType() == 'adminhtml/sales_order_grid') {
$data = array(
'label' => 'My button',
'class' => 'some-class',
'onclick' => 'setLocation(\' ' . Mage::getUrl('*/*', array('param' => 'value')) . '\')',
);
$container->addButton('my_button_identifier', $data);
}
return $this;
}
}
Am I missing something or is there a better way to add a custom button to the admin interface of a module?
Any help would be greatly appreciated.
Thanks
Varien_Event_Observer
. Make sure you removed your cache. Also look for any log errors