I have created a module with name as (Ownmodule_Autocancel). In this i added a button to front end at template file named as autocancel/autocancel.phtml.The process is,it should redirect by action controller like "say hiwhn click on it". But when i click on that button it is not triggered. I don't know how to trigger that here is autocancel.phtml
<form method="post" action = "<?php echo Mage::getUrl(); ?>" id="cancelorder">
<button type ="button" title="<?php echo $this->__('Cancel Pickup') ?>" class="button btn-checkout" onclick="setLocation('<?php echo Mage::registry('token'); ?>')"><span><span><?php echo $this->__('Cancel Pickup') ?></span></span></button></p>
And my controller.php file is
<?php
class Ownmodule_Autocancel_IndexController extends Mage_Core_Controller_Front_Action
{public function IndexAction(){
$this->loadLayout();
$this->getLayout()->getBlock('head')->setTitle($this->__('autocancel'));
//echo $this->getLayout()->createBlock('core/tempete')->setTemplete('autocancel/autocancel.phtml')->toHtml();
$this->renderLayout();
}
} ?>
It just show undefined page when click on that button.
In Template:
<form method="post" action = "<?php echo Mage::getUrl(); ?>" id="cancelorder">
Just replace
<?php echo Mage::getUrl(); ?>
with
<?php echo Mage::getBaseUrl(); ?>
and you should be redirected to the home page.
So if you create another action in you custom controller then, just append to the base url like,
echo Mage::getBaseUrl().'/autocancel/CONTROLLER/NEWACTION/';
Just read some basic Magento URL routing and u should be up and ready to go.
Your Class
class Ownmodule_Autocancel_IndexController extends Mage_Core_Controller_Front_Action
{public function IndexAction(){
$this->loadLayout();
$this->getLayout()->getBlock('head')->setTitle($this->__('autocancel'));
//echo $this->getLayout()->createBlock('core/tempete')->setTemplete('autocancel/autocancel.phtml')->toHtml();
$this->renderLayout();
}
//add another action
public function testAction(){
die('test');
}
To reach to this new action in your controller
<form method="post" action = "<?php echo Mage::getBaseUrl(); ?>/autocancel/index/test" id="cancelorder">
Basically you have..
MagentoBaseUrl + modulename/controllername/actionname
where, modulename = autocancel, controllername = index , action = test .
Hope this helps.