magento - creating admin controller - magento

I am having a admin module Siteadmin_Approval -
Here is confing.xml -
<config>
<modules>
<Siteadmin_Approval>
<version>1.4.0</version>
</Siteadmin_Approval>
</modules>
<frontend>
<routers>
<approval>
<use>standard</use>
<args>
<module>Siteadmin_Approval</module>
<frontName>approval</frontName>
</args>
</approval>
</routers>
<layout>
<updates>
<approval>
<file>approval.xml</file>
</approval>
</updates>
</layout>
</frontend>
<admin>
<routers>
<approval>
<use>admin</use>
<args>
<module>Siteadmin_Approval</module>
<frontName>approval</frontName>
</args>
</approval>
</routers>
</admin>
<adminhtml>
<menu>
<approval module="approval">
<title>Companies</title>
<sort_order>71</sort_order>
<children>
<sub_menu1 translate="title">
<title>Registered Comapnies</title>
<sort_order>10</sort_order>
<action>approval/adminhtml_approval</action>
</sub_menu1>
</children>
</approval>
</menu>
<acl>
<resources>
<admin>
<children>
<approval translate="title" module="approval">
<title>Payment Requests</title>
<sort_order>50</sort_order>
<children>
<items module="uploads">
<title>Requests</title>
<sort_order>0</sort_order>
<action>uploads/adminhtml_uploads</action>
</items>
</children>
</approval>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<uploads>
<file>approval.xml</file>
</uploads>
</updates>
</layout>
</adminhtml>
<global>
<blocks>
<approval>
<class>Siteadmin_Approval_Block</class>
</approval>
</blocks>
<helpers>
<approval>
<class>Siteadmin_Approval_Helper</class>
</approval>
</helpers>
</global>
</config>
controller is -
<?php
class Siteadmin_Approval_Adminhtml_ApprovalController extends Mage_Adminhtml_Controller_action
{
protected function _initAction() {
$this->loadLayout()
->_setActiveMenu('siteadmin/approval');
return $this;
}
public function indexAction() {
$this->_initAction()
->renderLayout();
}
public function rejectAction() {
echo "working"; die;
}
}
and layout file approval.xml contains -
<?xml version="1.0"?>
<layout version="1.4.0">
<approval_adminhtml_approval_index>
<reference name="content">
<block type="approval/adminhtml_approval" name="approval" />
</reference>
</approval_adminhtml_approval_index>
<approval_adminhtml_approval_reject>
<reference name="content">
<block type="approval/adminhtml_approval/reject" name="approval" />
</reference>
</approval_adminhtml_approval_reject>
</layout>
index action is working fine. But reject action is not getting called. If I print echo "===>".Mage::getUrl('approval/adminhtml_approval/reject'); then it only returns http://example.com/index.php/approval/adminhtml_approval/reject . It doesn't generate admin key in the url.
What's wrong in my layout xml?
Any help is appreciated.
Thanks.

actually except using this - Mage::getUrl('approval/adminhtml_approval/reject');
this works -
Mage::helper("adminhtml")->getUrl("approval/adminhtml_approval/reject");
all the settings in config and layout are correct.

Related

How to add some content in menu item admin panel Magento

I have create some menu and his sub menu in admin panel(it displays me a blank page) so i want to add some input then this input I want to do some SQL query (Save text in db), and this text i want to display it in some sms page. I dont know how.
Menu admin panel
W/Testimony/controllers/Adminhtml/TestimonyController.php
class W_Testimony_Adminhtml_TestimonyController extends Mage_Adminhtml_Controller_Action{
protected function _initAction() {
$this->_title($this->__('Paramétrage'))
->_title($this->__('Témoignage'));
$this->loadLayout()
->_setActiveMenu('testimony/parametrage')
->_addBreadcrumb(Mage::helper('adminhtml')->__('testimony'), Mage::helper('adminhtml')->__('testimony'))
->_addBreadcrumb(Mage::helper('adminhtml')->__('Paramétrage'), Mage::helper('adminhtml')->__('Paramétrage'));
return $this;
}
public function indexAction() {
$this->_initAction()
->renderLayout();
}
}
W/Testimony/etc/adminhtml.xml
<config>
<menu>
<testimony translate="title" module="testimony">
<title>Témoignage</title>
<sort_order>100</sort_order>
<children>
<parametrage translate="title" module="testimony">
<title>Paramétrage</title>
<sort_order>1</sort_order>
<action>adminhtml/testimony/index</action>
</parametrage>
</children>
</testimony>
</menu>
W/Testimony/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<W_Testimony>
<version>0.0.1</version>
</W_Testimony>
</modules>
<adminhtml>
<layout>
<updates>
<testimony>
<file>testimony.xml</file> <!-- I dont know what is this file ?-->
</testimony>
</updates>
</layout>
<acl>
<resources>
<admin>
<children>
<testimony>
<title>testimony Menu Item</title>
<children>
<parametrage translate="title" module="testimony">
<title>param Menu Item</title>
</parametrage>
</children>
</testimony>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<global>
<models>
<w_testimony>
<class>W_Testimony_Model</class>
</w_testimony>
</models>
<helpers>
<testimony>
<class>W_Testimony_Helper</class>
</testimony>
</helpers>
<blocks>
<w_testimony>
<class>W_Testimony_Block</class>
</w_testimony>
<w_testimony_adminhtml>
<class>W_Testimony_Block_Adminhtml</class>
</w_testimony_adminhtml>
</blocks>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<w_testimony after="Mage_Adminhtml">W_Testimony_Adminhtml</w_testimony>
</modules>
</args>
</adminhtml>
</routers>
</admin>
W/Testimony/Helper/Data.php
class W_Testimony_Helper_Data extends Mage_Core_Helper_Abstract{
}
W/Testimony/Model/Testimony.php
class W_Testimony_Model_Testimony extends Mage_Core_Model_Abstract{
public function _construct() {
$this->_isPkAutoIncrement = false;
$this->_init('w_testimony/testimony');
}
}
You can follow this instruction and create page in admin.
Create Module

magento controller not found

I have set up a controller in my module to add an order export tab to my installation:
in config.xml:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orderexport>abc_Orderexport_index2</orderexport>
</modules>
</args>
</adminhtml>
</routers>
<layout>
<updates>
<orderexport>
<file>orderexport.xml</file>
</orderexport>
</updates>
</layout>
</admin>
in adminhtml.xml:
<?xml version="1.0"?>
<config>
<menu>
<sales>
<children>
<orderexport>
<title>Order Export</title>
<sort_order>20</sort_order>
<action>adminhtml/index2</action>
</orderexport>
</children>
</sales>
</menu>
<acl>
<resources>
<admin>
<children>
<sales>
<children>
<orderexport>
<title>Order Export</title>
<sort_order>20</sort_order>
</orderexport>
</children>
</sales>
</children>
</admin>
</resources>
</acl>
</config>
and in the controllers/Adminhtml/Index2Controller.php file
class abc_Orderexport_Adminhtml_Index2Controller extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
However with all this done, whenever I click on the button "Order Export" it redirects me to the 404 page. That means that Magento cannot find the controller but idk why.
When i rename the controller everywhere from index2 into index (Index2Controller.php to IndexController.php) I am not getting redirected to the 404 page, HOWEVER the Dashboard of the admin panel just reloads.
I really don't know where my error is and Im happy for any hints into the right direction.
Here is what you have to fix:
in config.xml: you have to say that your module should be use in the adminhtml area, and you have to respect the CamelCase, here is how it should look like:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Abc_Orderexport after="Mage_Adminhtml">Abc_Orderexport_Adminhtml</Abc_Orderexport>
</modules>
</args>
</adminhtml>
</routers>
</admin>
in your controller, again, you must respect CamelCase, i.e. the class name is Abc_Orderexport_Adminhtml_Index2Controller
All this is assuming your folder structure is:
app/
code/
local/
Abc/
Orderexport/
controllers/
Adminhtml/
Index2Controller.php
etc/
config.xml
adminhtml.xml
, exactly, upper/lower case is important
Could you please try the following code and make sure that you module class name and folder structure must be in standard magento
extension structure. config.xml
<admin>
<routers>
<orderexport>
<use>admin</use>
<args>
<modules>
<orderexport>Abc_Orderexport_Index2</orderexport>
<frontName>orderexport</frontName>
</modules>
</args>
<orderexport>
</routers>
<layout>
<updates>
<orderexport>
<file>orderexport.xml</file>
</orderexport>
</updates>
</layout>
</admin>

adminhtml tag in config.xml file does not work

I am new to magento and making a custom module and want to work on admin end but after installing extension I get this error:
Fatal error: Class 'Submitdigital_CustomLogo_Helper_Data' not found in /var/zpanel/hostdata/zadmin/public_html/unisport_com/app/Mage.php on line 547
After insatalling extension when I clear cashe it give me this error. After somestudy I found that the error is due to this file at path:
app/code/local/Submitdigital/CustomLogo/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Submitdigital_CustomLogo>
<version>0.1.0</version>
</Submitdigital_CustomLogo>
</modules>
<global>
<helpers>
<customlogo>
<class>Submitdigital_CustomLogo_Helper</class>
</customlogo>
</helpers>
<blocks>
<customlogo>
<class>Submitdigital_CustomLogo_Block</class>
</customlogo>
</blocks>
<models>
<customlogo>
<class>Submitdigital_CustomLogo_Model</class>
<resourceModel>customlogo_mysql4</resourceModel>
</customlogo>
<customlogo_mysql4>
<class>Submitdigital_CustomLogo_Model_Mysql4</class>
<entities>
<customlogo>
<table>customlogo</table>
</customlogo>
</entities>
</customlogo_mysql4>
</models>
<resources>
<customlogo_setup>
<setup>
<module>Submitdigital_CustomLogo</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customlogo_setup>
<customlogo_write>
<connection>
<use>core_write</use>
</connection>
</customlogo_write>
<customlogo_read>
<connection>
<use>core_read</use>
</connection>
</customlogo_read>
</resources>
</global>
<admin>
<routers>
<admin_customlogo>
<use>admin</use>
<args>
<module>Submitdigital_CustomLogo</module>
<frontName>admin_customlogo</frontName>
</args>
</admin_customlogo>
</routers>
</admin>
<adminhtml>
<menu>
<customlogo module="customlogo">
<title>SubmitDigital</title>
<sort_order>100</sort_order>
<children>
<customlogo module="customlogo">
<title>Manage Customlogo</title>
<sort_order>0</sort_order>
<action>customlogo/adminhtml_customlogo</action>
</customlogo>
</children>
</customlogo>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<customlogo translate="title" module="customlogo">
<title>SubmitDigital</title>
<sort_order>1000</sort_order>
<children>
<customlogo translate="title">
<title>Manage Customlogo</title>
<sort_order>0</sort_order>
</customlogo>
</children>
</customlogo>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<customlogo>
<file>customlogo.xml</file>
</customlogo>
</updates>
</layout>
</adminhtml>
<frontend>
<routers>
<customlogo>
<use>standard</use>
<args>
<module>Submitdigital_CustomLogo</module>
<frontName>customlogo</frontName>
</args>
</customlogo>
</routers>
<layout>
<updates>
<customlogo>
<file>customlogo.xml</file>
</customlogo>
</updates>
</layout>
</frontend>
</config>
all goes well with the file but when I add <adminhtml>...</adminhtml> in the file it gives the above error and hence I am not able to see anything at my admin end.
Please Help
here is my customlogo.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<customlogo_adminhtml_customlogo_index>
<reference name="content">
<block type="customlogo/adminhtml_customlogo" name="customlogo" />
</reference>
</customlogo_adminhtml_customlogo_index>
</layout>
You have to create the helper class to fix this issue.
app/code/local/Submitdigital/CustomLogo/Helper/Data.php
class Submitdigital_CustomLogo_Helper_Data extends Mage_Core_Helper_Abstract
{
}
You have the following code to call the helper
<customlogo module="customlogo">
Here
module parameter is used to call the helper for translation.

Shows wrong url for a custom module magento

I have created a custom module 'Measurement'.and the frontend url is http://urbanior.grapesdigital.com/measurement/.
I want to add a link in left side like Measurements in my account page. so I added this in my measurement.xml page
measuement.xml
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="measurement"><name>grapes_measurement</name><path>measurement/</path><label>Measurements</label></action>
</reference>
</customer_account>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Grapes_Measurement>
<version>0.1.0</version>
</Grapes_Measurement>
</modules>
<frontend>
<routers>
<measurement>
<use>standard</use>
<args>
<module>Grapes_Measurement</module>
<frontName>measurement</frontName>
</args>
</measurement>
</routers>
<layout>
<updates>
<measurement>
<file>measurement.xml</file>
</measurement>
</updates>
</layout>
</frontend>
<global>
<helpers>
<measurement>
<class>Grapes_Measurement_Helper</class>
</measurement>
</helpers>
<blocks>
<measurement>
<class>Grapes_Measurement_Block</class>
</measurement>
</blocks>
<models>
<measurement>
<class>Grapes_Measurement_Model</class>
<resourceModel>measurement_mysql4</resourceModel>
</measurement>
<measurement_mysql4>
<class>Grapes_Measurement_Model_Mysql4</class>
<entities>
<measurement>
<table>measurements</table>
</measurement>
</entities>
</measurement_mysql4>
</models>
<resources>
<measurement_setup>
<setup>
<module>Grapes_Measurement</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</measurement_setup>
<measurement_write>
<connection>
<use>core_write</use>
</connection>
</measurement_write>
<measurement_read>
<connection>
<use>core_read</use>
</connection>
</measurement_read>
</resources>
</global>
<admin>
<routers>
<measurement>
<use>admin</use>
<args>
<module>Grapes_Measurement</module>
<frontName>admin_measurement</frontName>
</args>
</measurement>
</routers>
</admin>
<adminhtml>
<menu>
<measurement module="measurement">
<title>Measurement</title>
<sort_order>100</sort_order>
<children>
<measurement module="measurement">
<title>Manage Measurement</title>
<sort_order>0</sort_order>
<action>admin_measurement/adminhtml_measurement</action>
</measurement>
</children>
</measurement>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<measurement translate="title" module="measurement">
<title>Measurement</title>
<sort_order>1000</sort_order>
<children>
<measurement translate="title">
<title>Manage Measurement</title>
<sort_order>0</sort_order>
</measurement>
</children>
</measurement>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<measurement>
<file>measurement.xml</file>
</measurement>
</updates>
</layout>
</adminhtml>
</config>
But when I click on this link, it shows the url like http://urbanior.grapesdigital.com/admin_measurement/
It is taking the admin route path instead of frontend path. I don't know how to resolve this issue. It opens the same page but URL is different.
please check in config.xml you have same route "measurement" for admin please remove admin route or change it.

Magento admin menu link stopped working after upgrade

Before upgradation to EE v1.12.0.2, we were running v1.10.1.1, at which point this code works fine to add an external link to the menu.
<?xml version="1.0"?>
<config>
<modules>
<Clean_Integration>
<version>1.0.0</version>
</Clean_Integration>
</modules>
<global>
<models>
<customer>
<rewrite>
<customer_api>Clean_Integration_Model_Customer_Customer_Api</customer_api>
</rewrite>
</customer>
</models>
<helpers>
<coaching>
<class>Clean_Integration_Helper</class>
</coaching>
</helpers>
</global>
<frontend>
<layout>
<updates>
<Clean_Integration module="Clean_Integration">
<file>cleanintegration.xml</file>
</Clean_Integration>
</updates>
</layout>
</frontend>
<adminhtml>
<menu>
<coaching translate="title" module="Integration">
<title>Coaching</title>
<sort_order>71</sort_order>
<url>/appointments/sync/backend/</url>
</coaching>
</menu>
<acl>
<resources>
<admin>
<children>
<coaching translate="title">
<title>Coaching</title>
</coaching>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
We had a link like domain.com/appointments/sync/backend/ with this but now with upgrade the menu entry appears but its not a link anymore. So, I am guessing something was changed in Magento which breaks this, any ideas?
<?xml version="1.0"?>
<config>
<modules>
<Clean_Integration>
<version>1.0.0</version>
</Clean_Integration>
</modules>
<global>
<models>
<customer>
<rewrite>
<customer_api>Clean_Integration_Model_Customer_Customer_Api</customer_api>
</rewrite>
</customer>
</models>
<helpers>
<integration>
<class>Clean_Integration_Helper</class>
</integration>
</helpers>
</global>
<frontend>
<layout>
<updates>
<integration>
<file>cleanintegration.xml</file>
</integration>
</updates>
</layout>
</frontend>
<adminhtml>
<menu>
<integration translate="title" module="integration">
<title>Coaching</title>
<sort_order>71</sort_order>
<action>appointments/sync/backend/</action>
</integration>
</menu>
<acl>
<resources>
<admin>
<children>
<integration translate="title">
<title>Coaching</title>
</integration>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
Create in /app/code/local/Clean/Integration/Helper/Data.php
<?php
class Clean_Integration_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Take a look # Create a sample admin module for form processing

Resources