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
Related
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>
I have created a custom module, in the module when I click Save button sends request to catalog_products save function and save data to my extension's tables only(I have changed core file for this). Url on which I send request is:
localhost/magento/index.php/admin/admin/catalog_product/save/id/71/key5QDhzOH0ZRIgYZIC/?form_key=5QDhzOH0ZRIgYZIC&from_bpstore=yes
I have used ajax to save my data. And it is saving data when logged in from user having role "Administrator" but as I log in from any other user then it gives "Access Denied" error in response. Following is my config.xml for custom module:
<?xml version="1.0"?>
<config>
<modules>
<Bp_BpstoreInfo>
<version>0.1.0</version>
</Bp_BpstoreInfo>
</modules>
<global>
<helpers>
<bpstoreinfo>
<class>Bp_BpstoreInfo_Helper</class>
</bpstoreinfo>
</helpers>
<blocks>
<bpstoreinfo>
<class>Bp_BpstoreInfo_Block</class>
</bpstoreinfo>
</blocks>
</global>
<admin>
<routers>
<bpstoreinfo>
<use>admin</use>
<args>
<module>Bp_BpstoreInfo</module>
<frontName>bpstoreinfo</frontName>
</args>
</bpstoreinfo>
</routers>
</admin>
<adminhtml>
<menu>
<bpstoreinfo module="bpstoreinfo">
<title>Room Prices</title>
<sort_order>77</sort_order>
<action>bpstoreinfo/adminhtml_bpstoreinfobackend</action>
</bpstoreinfo>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<bpstoreinfo>
<title>bpstoreinfo Module</title>
<sort_order>1</sort_order>
</bpstoreinfo>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<bpstoreinfo>
<file>bpstoreinfo.xml</file>
</bpstoreinfo>
</updates>
</layout>
</adminhtml>
</config>
And my controller of custom module is
<?php
class Bp_BpstoreInfo_Adminhtml_BpstoreinfobackendController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->_title($this->__("Booking Prices"));
$this->renderLayout();
}
}
But when Ajax runs it sends data to catalog product module, Is this the problem that I am not able to save my data.
Please help I am totally stuck here. Thanks in Advance.
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.
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
Can any one please tell me how to override config controller in magento. I have attatched my config code below :
<config>
<modules>
<Adodis_Themechooser>
<version>0.1.0</version>
</Adodis_Themechooser>
</modules>
<adminhtml>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Adodis_Themechooser>
<title>Themechooser Module</title>
<sort_order>10</sort_order>
</Adodis_Themechooser>
<system>
<children>
<config>
<children>
<themechooser>
<title>Themechooser</title>
</themechooser>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<global>
<adminhtml>
<rewrite>
<themechooser_config>
<from><![CDATA[#^/admin/system_config/#]]></from>
<to>/themechooser/config/</to>
</themechooser_config>
</rewrite>
</adminhtml>
<models>
<themechooser>
<class>Adodis_Themechooser_Model</class>
</themechooser>
</models>
<helpers>
<themechooser>
<class>Adodis_Themechooser_Helper</class>
</themechooser>
</helpers>
</global>
</config>
An override of the config controller means you will be dealing with all presses of the Save Config button, not just your own themechooser page. That method of override means that no other module could ever make a compatible override of their own, and the "from/to" syntax is outdated anyway. Also an override is not needed at all, you're only interested in the saving of one field and that can be found through a backend_model.
Your module probably has an etc/system.xml file,
<config>
<sections>
<themechooser>
<groups>
<themechooser>
<fields>
<example translate="label">
<label>This is a text field</label>
<frontend_type>text</frontend_type>
<backend_model>themechooser/config_example</backend_model>
<show_in_default>1</show_in_default>
</example>
</fields>
</themechooser>
</groups>
</themechooser>
</sections>
</config>
Note the backend_model. Now make the class that fits themechooser/config_example,
class Adodis_Themechooser_Model_Config_Example extends Mage_Core_Model_Config_Data {
protected function _afterSave() {
$value = $this->getValue();
// $value is the text in the text field
}
}
All that remains is to use $value to set the frontend theme. The field can be any type, it does not have to be text.