Magento - How to create new admin page - magento

I'm using Magento 1.9.0.1 and i've created a new extension in which i've added a new tab in the admin panel take a look at the picture.
Here is what i have in my files.
In: /app/code/community/VivasIndustries/SmsNotification/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<VivasIndustries_SmsNotification>
<version>0.1.0</version>
</VivasIndustries_SmsNotification>
</modules>
<global>
<models>
<smsnotification>
<class>VivasIndustries_SmsNotification_Model</class>
</smsnotification>
</models>
<events>
<sales_order_save_after>
<observers>
<vivasindustries_smsnotification>
<class>smsnotification/observer</class>
<method>orderSaved</method>
</vivasindustries_smsnotification>
</observers>
</sales_order_save_after>
</events>
<helpers>
<smsnotification>
<class>VivasIndustries_SmsNotification_Helper</class>
</smsnotification>
<adminhtml>
<rewrite>
<data>VivasIndustries_SmsNotification_Helper_Adminhtml_Data</data>
</rewrite>
</adminhtml>
</helpers>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<VivasIndustries_SmsNotification before="Mage_Adminhtml">VivasIndustries_SmsNotification_Adminhtml</VivasIndustries_SmsNotification>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/etc/adminhtml.xml:
<?xml version="1.0"?>
<config>
<menu>
<vivassms translate="title" module="smsnotification">
<title>SMS Center</title>
<sort_order>110</sort_order>
<children>
<sendsms translate="title" module="smsnotification">
<title>Send SMS</title>
<action>adminhtml/magesms_sendsms</action>
<sort_order>1</sort_order>
</sendsms>
<settings>
<title>Settings</title>
<action>adminhtml/system_config/edit/section/vivas/</action>
<sort_order>10</sort_order>
</settings>
<about translate="title" module="smsnotification">
<title>About</title>
<action>adminhtml/smsnotification_about</action>
<sort_order>11</sort_order>
</about>
</children>
</vivassms>
</menu>
<acl>
<resources>
<admin>
<children>
<vivassms>
<title>SMS</title>
<children>
<sendsms translate="title" module="smsnotification">
<title>Send SMS</title>
</sendsms>
<settings>
<title>Settings</title>
<children>
<smsprofile translate="title" module="smsnotification">
<title>Edit user account</title>
</smsprofile>
</children>
</settings>
<about translate="title" module="smsnotification">
<title>About</title>
</about>
</children>
</vivassms>
<system>
<children>
<config>
<children>
<vivassms translate="title" module="smsnotification">
<title>Vivas SMS</title>
</vivassms>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
I've added these three children tabs to the created new tab SMS Center but when i click on the About tab i got error 404 ON MY FRONTEND. This is awkward. Why i got redirected to the frontend ?
Can you please help me out to create a simple new custom page in the admin panel where i want to add a simple text?
Thanks in advance!

Seems like Magento recognizes your module is telling it "Check me for admin" controllers, but that Magento doesn't find any. The best way to figure out what Magento thinks your controller file should be named (as well as which folder it should be located in) is to add some temporary debugging to _validateControllerClassName
protected function _validateControllerClassName($realModule, $controller)
{
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
var_dump($controllerFileName); //add this line
return false;
}
This will dump out every file Magento checks for a controller. Look for the line with your module name in it, and compare paths between where your file is located and where Magento thinks it should be located.

Related

Magento is adding Mage as class prefix when I access role permission in admin

Fatal error on admission permission: Fatal error: Class 'Mage_Mypack_Mymodule_Helper_Data' not found in /path/to/magento/app/Mage.php on line 516
My config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mypack_Mymodule>
<version>0.1.0</version>
</Mypack_Mymodule>
</modules>
<global>
<models>
<mymodule>
<class>Mypack_Mymodule_Model</class>
</mymodule>
</models>
<helpers>
<mypack_mymodule>
<class>Mypack_Mymodule_Helper</class>
</mypack_mymodule>
</helpers>
</global>
</config>
My admin.xml
<?xml version="1.0"?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<mmmymodle translate="title" module="Mypack_Mymodle">
<title>Mu module permission</title>
</mmmymodle>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
<mmmymodle translate="title" module="Mypack_Mymodle">
should be
<mmmymodle translate="title" module="mypack_mymodule">
Also, you should check if your module is enabled or not. (app/etc/modules/Mypack_Mymodule.xml)

Magento - Can't Save Role Resource for Custom Module

I’ve created a custom module and my config.xml is as follows…
<?xml version="1.0"?>
<config>
<admin>
<routers>
<blacklist>
<use>admin</use>
<args>
<module>Leon_Blacklist</module>
<frontName>blacklist</frontName>
</args>
</blacklist>
</routers>
</admin>
<adminhtml>
<menu>
<blacklist translate="title" module="blacklist">
<title>Blacklist</title>
<sort_order>71</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
<sort_order>0</sort_order>
<action>blacklist/adminhtml_blacklist</action>
</items>
</children>
</blacklist>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Leon_Blacklist translate="title" module="blacklist">
<title>Blacklist Module</title>
<sort_order>10</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
</items>
</children>
</Leon_Blacklist>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<blacklist>
<file>blacklist.xml</file>
</blacklist>
</updates>
</layout>
</adminhtml>
<config>
The module works as expected if an admin account is logged in. I can see the module in the admin panel and in the Role Resource Tab (System->Permissions->Roles), but when I tried to check the module and save the user role, it will say that it has been saved. But when I rechecked the user role, it is still unchecked.
And when I tried to login using the account with the said user role, the custom module is hidden. What seems to be the problem? Any kind of help is much appreciated..
Thanks.
Your acl section of config is a little wrong. Tags should be similar to menu section. So in your case it should look like this:
<acl>
<resources>
<admin>
<children>
<blacklist translate="title" module="blacklist">
<title>Blacklist Module</title>
<sort_order>10</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
</items>
</children>
</blacklist>
</children>
</admin>
</resources>
</acl>
Here is my acl section of config.xml
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<banner translate="title" module="banner">
<title>Banner Module</title>
<sort_order>10</sort_order>
<children>
<banner translate="title" module="banner">
<title>Manage Banners</title>
</banner>
</children>
</banner>
</children>
</admin>
</resources>
</acl>
Also add the below function in your controller to avoid the "Access denied" message
protected function _isAllowed(){
return true;
}
Code taken from: http://chandreshrana.blogspot.in/2015/06/custom-module-role-not-save-in.html

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

Magento : Overriding Config Controller?

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.

Magento Custom Module Admin Permissions

I have created a few custom modules for Magento and when I try to assign permissions to the module (check the checkbox) when I click save it unchecks the box.
Anyone have any ideas? It sort of sounds like there is something off in my config.xml file so I will post it here just in case:
<config>
<modules>
<Wpe_Vendorlist>
<version>0.1.0</version>
</Wpe_Vendorlist>
</modules>
<admin>
<routers>
<vendorlist>
<use>admin</use>
<args>
<module>Wpe_Vendorlist</module>
<frontName>vendorlist</frontName>
</args>
</vendorlist>
</routers>
</admin>
<adminhtml>
<menu>
<customer>
<children>
<items module="vendorlist">
<title>SO Vendor List</title>
<sort_order>999</sort_order>
<action>vendorlist/adminhtml_vendorlist</action>
</items>
</children>
</customer>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Wpe_Vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</Wpe_Vendorlist>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<vendorlist>
<file>vendorlist.xml</file>
</vendorlist>
</updates>
</layout>
</adminhtml>
<global>
<models>
<vendorlist>
<class>Wpe_Vendorlist_Model</class>
<resourceModel>vendorlist_mysql4</resourceModel>
</vendorlist>
<vendorlist_mysql4>
<class>Wpe_Vendorlist_Model_Mysql4</class>
<entities>
<vendorlist>
<table>vendorlist</table>
</vendorlist>
</entities>
</vendorlist_mysql4>
</models>
<resources>
<vendorlist_setup>
<setup>
<module>Wpe_Vendorlist</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</vendorlist_setup>
<vendorlist_write>
<connection>
<use>core_write</use>
</connection>
</vendorlist_write>
<vendorlist_read>
<connection>
<use>core_read</use>
</connection>
</vendorlist_read>
</resources>
<blocks>
<vendorlist>
<class>Wpe_Vendorlist_Block</class>
</vendorlist>
</blocks>
<helpers>
<vendorlist>
<class>Wpe_Vendorlist_Helper</class>
</vendorlist>
</helpers>
</global>
</config>
I strongly recomend you to take a look at Alan Storm's article about system configuration, and the rest of his serie, it's the best info I've found about magento programing.
For this particular question, here is how I've done it in my module, with your module name:
<acl><!-- permits -->
<resources>
<admin>
<children>
<customer translate="title" module="vendorlist"><!-- this tag matches the menu tag, and the same for his children -->
<title>what will appears in the checkboxes tree when you create a role</title>
<children>
<firstchild>
<title>what will appears in the checkboxes tree when you create a role</title>
</firstchild>
</children>
</customer>
</children>
</admin>
</resources>
</acl>
You won't need the:
<children>
<firstchild>
<title>what will appears in the checkboxes tree when you create a role</title>
</firstchild>
</children>
as you don't have children in your module, it seems, I just put it as an example.
I hope this helps
Please change your config.xml and replace
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Wpe_Vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</Wpe_Vendorlist>
</children>
</admin>
</resources>
</acl>
with
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</vendorlist>
</children>
</admin>
</resources>
</acl>
Only need to change vendorlist after children tag instead of Wpe_Vendorlist. This change worked for me in my custom module,hope may help others also.
You should use only lower case characters in your resource and menu item names. See the constructor on app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
public function __construct()
{
...
foreach ($rules_set->getItems() as $item) {
$itemResourceId = $item->getResource_id();
if (array_key_exists(strtolower($itemResourceId), $resources) && $item->getPermission() == 'allow') {
$resources[$itemResourceId]['checked'] = true;
array_push($selrids, $itemResourceId);
}
}
....
I would also suggest you consider moving the acl and menu info to adminhtml.xml instead of having it on config.xml.
Another issue is that you should have exactly the same structure in both menu and acl trees, so your acl reflects the menu structure and magento knows what to enable when a permission is given to a role. There's a great article by Ivan Chepurnyi about this here
So, after the changes, you would end up with someting similar to this, on adminhtml.xml:
<adminhtml>
<menu>
<customer>
<children>
<wpe_vendorlist module="vendorlist">
<title>SO Vendor List</title>
<sort_order>999</sort_order>
<action>vendorlist/adminhtml_vendorlist</action>
</wpe_vendorlist>
</children>
</customer>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<customer>
<children>
<wpe_vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</wpe_vendorlist>
</children>
</customer>
</children>
</admin>
</resources>
</acl>
</adminhtml>
I found something from magento forum. Go to the following link:
http://www.magentocommerce.com/boards/viewthread/78673/
But still can't set permission to these custom modules from newly created roles.
These custom modules didn't appear in main menu for that newly created roles' users.
after changing syntax in acl tag module is displayed in custom module permission

Resources