404 error in Custom Magento configuration in admin - magento

I'm developing a custom SMS module in Magento 1.6.
I've setup the system.xml file to manage the related custom configuration fields.
The menu entry shows up, but when I click it, a 404 error page is shown instead of the expected configuration fields list.
Can you see any errors in my code?
<config>
<tabs>
<mynew_tab translate="label">
<label>SMS Gateway Integration</label>
<sort_order>100</sort_order>
</mynew_tab>
</tabs>
<sections>
<smsconfig translate="label">
<label>SMS Gateway Integration</label>
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<tab>mynew_tab</tab>
<groups>
<sms_group translate="label">
<label>My Custom Configurations</label>
<comment>This is example of custom configuration.</comment>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<sms_enabled translate="label tooltip comment">
<label>Is Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Enable this module.</comment>
</sms_enabled>
<sms_username translate="label tooltip comment">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Username of the SMS gateway.</comment>
</sms_username>
<sms_password translate="label tooltip comment">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Password of the SMS gateway.</comment>
</sms_password>
</fields>
</sms_group>
</groups>
</smsconfig>
</sections>
After ben's request, we placed the adminhtml.xml file. I placed the content of the XML file.
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<sms translate="title" module="sms">
<title>SMS Gateway Section</title>
</sms>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
But till the 404 error comes...

A 404 error in system configuration often means that there is an issue with ACL. You are likely missing the appropriate acl node in your module's adminhtml.xml file:
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<smsconfig> <!-- translate="title" module="sms_config" if appropriate and depending on config -->
<title>Your Section</title>
</...>
After adding the above you will need to log out and log back in for full admin role users and explicitly add this role to custom admin user roles.

Do what #benmarks said plus be sure to add the right children (in your case) smsconfig
(#benmarks used sms_config instead of smsconfig)
<!-- namespace/modulename/etc/adminhtml.xml -->
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<smsconfig> <!-- translate="title" module="sms_config" if appropriate and depending on config -->
<title>Your Section</title>
</...>
clear cache, admin logout, admin login == works
Hint: If you get 404 look at the url (when you clicked on your tab):
/index.php/admin/system_config/edit/section/mymodulename_something/...
This url seems to point to mymodulename_something:
<!-- namespace/modulename/etc/system.xml -->
<?xml version="1.0"?>
<config>
<tabs>
<mymodulename translate="label" module="mymodulename">
<label>MyModuleName Awesome Label</label>
<sort_order>1</sort_order>
</mymodulename>
</tabs>
<sections>
<mymodulename_something translate="label" module="mymodulename">
<!-- ... -->
so your adminhtml.xml would look like:
<!-- namespace/modulename/etc/adminhtml.xml -->
<?xml version="1.0"?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<mymodulename_something translate="title" module="mymodulename">
<title>have no idea where this is showing up btw</title>
</mymodulename_something>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>

Don't underestimate the need to log out and then log back in after making ACL changes. Even if you clear your cache, you will still 404 until you log out and log back in.

Related

Move magento module from navigation menu to a tab in the admin configuration

I have a widget grid type module, which i want to move into magento system config.
I have added the following into my system.xml:
<config>
<sections>
<customesetup>
<groups>
<serialnumbervalidator>
<label>Serial Numbers</label>
<sort_order>20</sort_order>
<expanded>1</expanded>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<frontend_class>complex</frontend_class>
<frontend_model>mymodule/adminhtml_serial</frontend_model>
</serialnumbervalidator>
</groups>
</customesetup>
</sections>
</config>
but apparently it shows nothing. as the Block extends Mage_Adminhtml_Block_Widget_Grid_Container .
If anyone can point me where to look for my answer this would be great (Did searches and did not find anything useful).
You have to modify your config.xml, to show this up in System Configuration section.
<adminhtml>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<YOUR_MODULE translate="title">
<title><![CDATA[MY TITLE]]></title>
<sort_order>2100</sort_order>
</YOUR_MODULE>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
[...]
</adminhtml>
And in your system.xml :
<config>
<tabs>
<YOUR_MODULE_tab translate="label" module="YOUR_MODULE">
<label>YOUR_MODULE</label>
<sort_order>150</sort_order>
<class>container_admin_img</class> /*optionnal*/
</YOUR_MODULE_tab>
</tabs>
<sections>
<customesetup>
<groups>
<serialnumbervalidator>
<label>Serial Numbers</label>
<sort_order>20</sort_order>
<expanded>1</expanded>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<frontend_class>complex</frontend_class>
<frontend_model>mymodule/adminhtml_serial</frontend_model>
</serialnumbervalidator>
</groups>
</customesetup>
</sections>
</config>
Hope this helps.
Take a look at Alan Storm's No Frills Magento Layout book, or on his website : http://alanstorm.com/category/magento

Magento ad variable in phtml

We have a file for one of our affiliates and want to call a static block in a phtml file.
It has to be in here:
$domain = "domain.com";
The domain.com has to be a variable and I think it would be best to give it a static block so I can put my own variable there. It is for a multistore so every storeview need to have it's own variable.
Let me know if someone knows how to do this.
If the required domain is the current store url
To use the domain name for the current url
$domain = Mage::getBaseUrl();
If the required domain is different to the current store url
I would make this part of the system configuration.
Create a new module
app/code/local/Vendor/Module/etc/config.xml
<config>
<modules>
<Juno_ProductRegion>
<version>0.1.0</version>
</Juno_ProductRegion>
</modules>
<global>
<helpers>
<vendor_module>
<class>Vendor_Module_Helper</class>
</vendor_module>
</helpers>
</global>
</config>
app/code/local/Vendor/Module/etc/system.xml
<config>
<tabs>
<vendor translate="label" module="module">
<label>Vendor</label>
</vendor>
</tabs>
<sections>
<vendor translate="label" module="module">
<label>Module</label>
<tab>vendor</tab>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general translate="label">
<label>General</label>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<affiliate_url translate="label">
<label>Affiliate URL</label>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</affiliate_url>
</fields>
</general>
</groups>
</vendor>
</sections>
</config>
app/code/local/Vendor/Module/etc/adminhtml.xml
<config>
<acl>
<admin>
<children>
<system>
<children>
<config>
<children>
<vendor>
<title>Vendor</title>
</vendor>
</children>
</config>
</children>
</system>
</children>
</admin>
</acl>
</config>
That would create a tab and section in System -> Configuration where you can enter the affiliate url for each store.
To fetch the affiliate url you would use
<?php echo Mage::getStoreConfig('vendor/general/affiliate_url'); ?>

Magento - Adminhtml new custom Tab in the config section is not showing up

i'm using Magento 1.9.0.1 and right now i am working on a new extension and i want to add new module with tab in the admin panel.
Here is what i've done so far:
/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>
</global>
<adminhtml>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<vivas>
<title>Vivas - All</title>
</vivas>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
Here is what i have in:
/app/code/community/VivasIndustries/SmsNotification/etc/system.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<tabs>
<vivas translate="label" module="vivasindustries_smsnotification">
<label>Vivas Extensions</label>
<sort_order>100</sort_order>
</vivas>
</tabs>
<sections>
<vivas translate="label" module="vivasindustries_smsnotification">
<label>Extension Options</label>
<tab>vivas</tab>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<vivas_group translate="label" module="vivasindustries_smsnotification">
<label>My Extension Options</label>
<frontend_type>text</frontend_type>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<vivas_input translate="label">
<label>My Input Field: </label>
<comment>My Comment</comment>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</vivas_input>
<vivas_select translate="label">
<label>My Dropdown: </label>
<comment>Source model provider Magento's default Yes/No values</comment>
<frontend_type>select</frontend_type>
<sort_order>90</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_yesno</source_model>
</vivas_select>
</fields>
</vivas_group>
</groups>
</vivas>
</sections>
</config>
Here is what i have in: /app/code/community/VivasIndustries/SmsNotification/Helper/Data.php:
<?php
class VivasIndustries_SmsNotification_Helper_Data extends Mage_Core_Helper_Abstract
{
}
With this done i receive the following error when i open my admin panel:
Fatal error: Class 'Mage_Vivasindustries_Smsnotification_Helper_Data' not found in /home/superweb/public_html/store/app/Mage.php on line 547
When i change the name of the FOLDER SmsNotification to Smsnotification this error is gone, but there is any new tab in the System->Configuration...
So guys can you help me out to create a new tab in the Admin panel ?
Thanks in advance!
You forgot to define the helper alias for your module in config.xml. It should be in the same form as for the models:
<global>
<helpers>
<smsnotification>
<class>VivasIndustries_SmsNotification_Helper</class>
</smsnotification>
</helpers>
...
Also, you have to use the same alias in system.xml when specifying the module used for translation:
module="smsnotification"
To explain what has happened: Magento doesn't find a helper with the alias "vivasindustries_smsnotification", so it falls back to the Mage namespace and the given alias with capitalized letters as module (no, I have never seen a case where this would have been the desired behavior, but this is how it works). This results in Mage_Vivasindustries_Smsnotification_Helper_Data as helper class name which cannot be found.
As a general rule: If Magento tries to load classes from your module with "Mage_" prefix, your module configuration is either incomplete, has errors or is cached with an old version and the configuration cache must be cleared.

How to add multiple sections under same tab magento admin panel?

I am trying to add multiple section under same tab in magento admin panel. I added this in system.xml file. It works fine for one section but when i add another it display the section but after click it throw 404 not fount error.
I am using the below code :
<tabs>
<mss translate="label" module="sqlite">
<label>Mss Extensions</label>
<sort_order>100</sort_order>
</mss>
</tabs>
<sections>
<mss translate="label" module="sqlite">
<label>Auto Indexing</label>
<tab>mss</tab>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<mss_group translate="label" module="sqlite">
<label>Indexing Options</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<mss_input translate="label">
<label>Auto Products</label>
<frontend_type>select</frontend_type>
<sort_order>90</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_yesno</source_model>
</mss_input>
</fields>
</mss_group>
</groups>
</mss>
</sections>
<sections
<sqlite translate="label" module="sqlite">
<label>Auto Indexing</label>
<tab>mss</tab>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<sqlite_group translate="label" module="sqlite">
<label>Sqlite Process</label>
<frontend_type>text</frontend_type>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<sqlite_input translate="label">
<label>Sqlite Product</label>
<frontend_type>select</frontend_type>
<sort_order>90</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>adminhtml/system_config_source_yesno</source_model>
</sqlite_input>
</fields>
</sqlite_group>
</groups>
</sqlite>
</sections>
1 ) This is my mss section this works fine
2) This is section which i am trying to with name sqlite (when i click on this section this throws 404 error)
Please help me how to add new section in tab or where i am doing wrong.
Please change adminhtml.xml file in your module as shown below :
<?xml version="1.0"?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<mss translate="title" module="sqlite">
<title>Auto Indexing</title>
<sort_order>0</sort_order>
</mss>
<sqlite translate="title" module="sqlite">
<title>Auto Indexing</title>
<sort_order>1</sort_order>
</sqlite>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
And then clear your magento cache and session.
Please check your modules config.xml. In it check if this section exists if not add it
<adminhtml>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<mss>
<title>Mss - All</title>
</mss>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
This should solve 404 error.

How to add my extension to Magento Admin Menu Sidebar?

I am working on creating my very first community extension. It is a very simple one and is already working. I would like to learn how to add my extension to the admin area that will allow the customer to disable or enable it. What do I need to add to my module to be able to do this? Any help would be great!
Here is my code:
app/etc/modules/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Module_Name>
<!-- Whether our module is active: true or false -->
<active>true</active>
<!-- Which code pool to use: core, community or local -->
<codePool>community</codePool>
</Module_Name>
</modules>
</config>
etc/system.xml
<?xml version="1.0"?>
<config>
<sections>
<module translate="label" module="modulename">
<label>Your Module Name</label>
<tab>tab_id_where_you_want_to_add_your_section</tab>
<frontend_type>text</frontend_type>
<sort_order>980</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<groups>
<modulename>
<label>Your Group Title</label>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<comment translate="label comment">
<label>Your Field Title</label>
<comment>Your Comment</comment>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</comment>
</fields>
</modulename>
</groups>
</your_module>
</sections>
</config>
etc/adminhtml.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<menu>
<modulename translate="title" module="shipping">
<title>Module</title>
<sort_order>15</sort_order>
<children>
<modulename translate="title" module="modulename">
<title>Drop Down Shipping</title>
<sort_order>1</sort_order>
<action>adminhtml/shipping/index</action>
</example>
</children>
</modulename>
</menu>
<layout>
<updates>
<modulename>
<file>shipping.xml</file>
</modulename>
</updates>
</layout>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<modulename translate="title" module="shipping">
<title>Your Module Name</title>
</modulename>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Module_Name>
<version>0.0.1</version>
</Module_Name>
</modules>
<frontend>
<layout>
<updates>
<modulename>
<file>shipping.xml</file>
</modulename>
</updates>
</layout>
</frontend>
<global>
<helpers>
<modulename>
<class>Module_Name_Helper</class>
</modulename>
</helpers>
</global>
</config>
My theme Layout XML File:
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_cart_index>
<reference name="head">
<action method="addCss"><stylesheet>css/module/shipping.css</stylesheet></action>
</reference>
<reference name="checkout.cart.shipping">
<action method="setTemplate"><template>module/shipping.phtml</template></action>
</reference>
</checkout_cart_index>
</layout>
Helper/Data.php
<?php
class Module_Name_Data extends Mage_Core_Helper_Abstract
{
}
It is not quite clear from your question if you want to add node to main admin menu (horizontal one with fly-out sub-menus) or sidebar menu of System\Configuration screen. Below are instructions how to add section, group and field to Magento configuration screen.
First you need the etc/system.xml file to your module:
<?xml version="1.0"?>
<config>
<sections>
<your_module translate="label" module="your_module_shortcode">
<label>Your Module Name</label>
<tab>tab_id_where_you_want_to_add_your_section</tab>
<frontend_type>text</frontend_type>
<sort_order>980</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<groups>
<your_group_name>
<label>Your Group Title</label>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<your_field_name translate="label comment">
<label>Your Field Title</label>
<comment>Your Comment</comment>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</your_field_name>
</fields>
</your_group_name>
</groups>
</your_module>
</sections>
</config>
And then add the following section to your etc/adminhtml.xml. It adds your newly created section to ACL so you will be able to control admin roles that can access it:
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<your_module translate="title" module="your_module_shortcode">
<title>Your Module Name</title>
</your_module>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
The enable and disable module feature is already exist in System >> Configuration >> ADVANCE >> Advance.
BTW if you want to add Menu in the System >> Configuration page, this article may help you http://alanstorm.com/custom_magento_system_configuration.
And if you got an error, check again whether everything is ok or not.

Resources