1

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!

Venelin
  • 2,905
  • 7
  • 53
  • 117

1 Answers1

3

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.

Fabian Schmengler
  • 24,155
  • 9
  • 79
  • 111