Hi All I am trying to develop a section on Magento Admin Dashboard Just Like Life time sales and Average orders. Example
I have overridden Dashboard.php block to add my custom block as its child in __prepareLayout() function Here is my dashboard.php code :
protected function _prepareLayout()
{
$this->setChild('lastOrders',
$this->getLayout()->createBlock('adminhtml/dashboard_orders_grid')
);
$this->setChild('totals',
$this->getLayout()->createBlock('adminhtml/dashboard_totals')
);
$this->setChild('sales',
$this->getLayout()->createBlock('adminhtml/dashboard_sales')
);
/* Here is my custom child block */
$this->setChild('totalOrders',
$this->getLayout()->createBlock('dashboard/adminhtml_totalorders')
);
/* custom code end here */
$this->setChild('lastSearches',
$this->getLayout()->createBlock('adminhtml/dashboard_searches_last')
);
$this->setChild('topSearches',
$this->getLayout()->createBlock('adminhtml/dashboard_searches_top')
);
if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
$block = $this->getLayout()->createBlock('adminhtml/dashboard_diagrams');
} else {
$block = $this->getLayout()->createBlock('adminhtml/template')
->setTemplate('dashboard/graph/disabled.phtml')
->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
}
$this->setChild('diagrams', $block);
$this->setChild('grids',
$this->getLayout()->createBlock('adminhtml/dashboard_grids')
);
Mage_Adminhtml_Block_Template::_prepareLayout();
}
Here is my child block code :
class Custom_Dashboard_Block_Adminhtml_Totalorders extends Mage_Adminhtml_Block_Dashboard_Bar
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('custom/dashboard/totalorders.phtml');
}
}
I tried putting exit() or die() in my it and it worked child block is calling but i don't know why phtml is not loading.
My phtml path is design/adminhtml/default/default/template/custom/dashboard/totalorders.phtml
Here is my config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Custom_Dashboard>
<version>0.1.0</version>
</Custom_Dashboard>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<dashboard>Custom_Dashboard_Block_Adminhtml_Dashboard</dashboard>
</rewrite>
</adminhtml>
<dashboard>
<class>Custom_Dashboard_Block</class>
</dashboard>
</blocks>
</global>
</config>
Any help Will be appreciable.