I am calling a method written in controller file from a block file as shown in below code--
BLOCK FILE
class Assel_Sms_Block_Adminhtml_Sendpushmsg extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);
$buttonHtml = $this->_getAddRowButtonHtml($this->__('Send Push Message'));
return $buttonHtml;
}
protected function _getAddRowButtonHtml($title)
{
$buttonBlock = $this->getElement()->getForm()->getParent()->getLayout()->createBlock('adminhtml/widget_button');
$_websiteCode = $buttonBlock->getRequest()->getParam('website', null);
$params = array();
if(!empty($_websiteCode)) {
$params['website'] = $_websiteCode;
}
// TODO: for real multi-store self-testing, the test button (and other configuration options)
// should probably be set to show in website. Currently they are not.
$url = Mage::helper('adminhtml')->getUrl("*/pushmessage_sendpushmsg/sendpushnotification", $params);
$buttonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setLabel($this->__($title))
->setOnClick("window.location.href='".$url."'")
->toHtml();
return $buttonHtml;
}
}
In above file code $url = Mage::helper('adminhtml')->getUrl("*/pushmessage_sendpushmsg/sendpushnotification", $params);
is calling my controller method.but it is showing 404 page.
What I gonna do is I want to call above controller on click a button on system configuration page. as shown in below image-
Here is controller method--
<?php
class Assel_Sms_Pushmessage_SendpushmsgController extends Mage_Adminhtml_Controller_Action {
public function sendpushnotificationAction() {
$_helper = Mage::helper('sms');
$_helper->log($_helper->__("Could not find required database tables"));
return;
}
}
EDITED--
Config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Assel_Sms>
<version>1.0.2</version>
</Assel_Sms>
</modules>
<admin>
<routers>
<sms>
<use>admin</use>
<args>
<module>Assel_Sms</module>
<frontName>sms</frontName>
</args>
</sms>
</routers>
</admin>
<frontend>
<routers>
<sms>
<use>standard</use>
<args>
<module>Assel_Sms</module>
<frontName>sms</frontName>
</args>
</sms>
</routers>
</frontend>
<global>
<models>
<sms>
<class>Assel_Sms_Model</class>
</sms>
</models>
<blocks>
<sms>
<class>Assel_Sms_Block</class>
</sms>
</blocks>
<helpers>
<sms>
<class>Assel_Sms_Helper</class>
</sms>
</helpers>
<rewrite>
<sms_customer_accountcontroller>
<from><![CDATA[#^/customer/account/#]]></from>
<to>/sms/customer_account/</to>
</sms_customer_accountcontroller>
</rewrite>
<events>
<sales_order_place_after>
<observers>
<sms>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsAfterOrder</method>
</sms>
</observers>
</sales_order_place_after>
<sales_order_invoice_save_after>
<observers>
<sms>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsAfterInvoice</method>
</sms>
</observers>
</sales_order_invoice_save_after>
<sales_order_creditmemo_save_after>
<observers>
<sms>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsAfterCreditmemo</method>
</sms>
</observers>
</sales_order_creditmemo_save_after>
<catalog_product_save_after>
<observers>
<sms>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsNotifyMe</method>
</sms>
</observers>
</catalog_product_save_after>
<customer_register_success>
<observers>
<sms_customer_register_success>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsOnCustomerCreate</method>
</sms_customer_register_success>
</observers>
</customer_register_success>
<sales_order_save_after>
<observers>
<sms>
<type>singleton</type>
<class>sms/observer</class>
<method>sendSmsOnOrderCancel</method>
</sms>
</observers>
</sales_order_save_after>
<controller_action_postdispatch_customer_account_forgotpasswordpost>
<observers>
<sms>
<class>sms/observer</class>
<method>sendSmsOnForgotPassword</method>
</sms>
</observers>
</controller_action_postdispatch_customer_account_forgotpasswordpost>
</events>
</global>
</config>