I am working on a demo Magento store (CE v1.7)
I want to generate a link for an action (index) of a controller (index) of the module (Mymodule), I want to display the link in the home page so I can access to Mymodule functionnality directly
how can I achieve this (without disabling the keys generation)?
I have already tried the following code, but I get redurected to the dashboard:
<?php $key = Mage::getSingleton('adminhtml/url')->getSecretKey("acompany_mymodule/index/","index"); ?>
<a href="<?php echo Mage::helper("adminhtml")->getUrl("acompany_mymodule/index/index/",array("key" => $key)); ?>">My action </a>
A secret key should automatically be added to the URL when using
provided that secret keys are enabled in the system config.
Anyway, in this part of your code :
you give as first parameter a route with a controller, where the method is just waiting for a controller name.
DON'T USE anything else than
adminhtml/
as start of the url, because magento 1.9.2.2 forbids everything else.The other solutions did not work for me as they did not include the Admin Panel base URL (admin by default). I had to do it like this to get the correct URL:
use following code for get url with secret code
Please refer to the following article: Generating Backend-Admin URL With Key and Parameters in Magento.
DON'T USE anything else than
adminhtml/
as start of the url, because magento 1.9.2.2 forbids everything else.