0

I've recently started doing Magento tutorials, since I'm starting a Magento job soon and they've asked me to study up on it so that I don't end up completely out of my depth when I start there.

I'm currently going through this and have hit a snag on page 11. At least, I think I have. I'm not sure, which is why I'm posting this question.

At this point, I have the following:

app/etc/modules/Magentostudy_News.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Magentostudy_News>
            <active>true</active>
            <codePool>community</codePool>
            <depends>
                <Mage_adminhtml/>
            </depends>
        </Magentostudy_News>
    </modules>
</config>

app/code/community folder structure

Magentostudy
  News
    Block
    controller
    data
      magentostudy_news_setup
    etc
      config.xml
    Helper
    Model
    sql
      magentostudy_news_setup

app/code/community/Magentostudy/News/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Magentostudy_News>
            <version>1.0.0.0.1</version>
        </Magentostudy_News>
    </modules>

    <global>
        <models>
            <magentostudy_news>
                <class>Magentostudy_News_Model</class>
                <resourceModel>news_resource</resourceModel>
            </magentostudy_news>

            <news_resource>
                <class>Magentostudy_New_Model_Resource</class>
                <entities>
                    <news>
                        <table>magentostudy_news</table>
                    </news>
                </entities>
            </news_resource>
        </models>

        <helpers>
            <magentostudy_news>
                <class>Magentostudy_News_Helper</class>
            </magentostudy_news>
        </helpers>

        <blocks>
            <magentostudy_news>
                <class>Magentostudy_News_Block</class>
            </magentostudy_news>
        </blocks>

        <resources>
            <magentostudy_news_setup>
                <setup>
                    <module>Magentostudy_News</module>
                    <class>Mage_Core_Model_Resource_Setup</class>
                </setup>
            </magentostudy_news_setup>
        </resources>

        <events>
            <before_news_item_display>
                <observers>
                    <magentostudy_news>
                        <class>magentostudy_news/observer</class>
                        <method>beforeNewsDisplayed</method>
                    </magentostudy_news>
                </observers>
            </before_news_item_display>
        </events>
    </global>

    <frontend>
        <routers>
            <magentostudy_news>
                <use>standard</use>
                <args>
                    <module>Magentostudy_News</module>
                    <frontName>news</frontName>
                </args>
            </magentostudy_news>
        </routers>
        <layout>
            <updates>
                <magentostudy_news>
                    <file>magentostudy_news.xml</file>
                </magentostudy_news>
            </updates>
        </layout>
    </frontend>
    <Admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Magentostudy_News before="Mage_adminhtml">Magentostudy_News_adminhtml</Magentostudy_News>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </Admin>
    <adminhtml>
        <layout>
            <updates>
                <magentostudy_news>
                    <file>magentostudy_news.xml</file>
                </magentostudy_news>
            </updates>
        </layout>
    </adminhtml>
    <default>
        <news>
            <view>
                <enabled>1</enabled>
                <items_per_page>20</items_per_page>
                <days_difference>3</days_difference>
            </view>
        </news>
    </default>
</config>

In other words, I have the bare basic start of a new Module.

I tried checking the admin configuration panel to ensure that my module was being picked up. I have disabled my cache, and double checked to make sure that nothing was actually cached.

When I try to access any page, I get the following error:

Module "Magentostudy_News" requires module "Mage_adminhtml".

#0 D:\Work\Development\wamp\www\magento1\app\code\core\Mage\Core\Model\Config.php(849): Mage::throwException('Module "Magento...')
#1 D:\Work\Development\wamp\www\magento1\app\code\core\Mage\Core\Model\Config.php(812): Mage_Core_Model_Config->_sortModuleDepends(Array)
#2 D:\Work\Development\wamp\www\magento1\app\code\core\Mage\Core\Model\Config.php(315): Mage_Core_Model_Config->_loadDeclaredModules()
#3 D:\Work\Development\wamp\www\magento1\app\code\core\Mage\Core\Model\App.php(425): Mage_Core_Model_Config->loadModules()
#4 D:\Work\Development\wamp\www\magento1\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Model_App->_initModules()
#5 D:\Work\Development\wamp\www\magento1\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#6 D:\Work\Development\wamp\www\magento1\index.php(83): Mage::run('', 'store')
#7 {main}

I think I might have made a mistake somewhere in the config.xml, but I have compared my code with the tutorial and I can't find anything wrong.

Is there anything else that I missed? The tutorial treats Mage_adminhtml as though it's part of the core Magento package, but I am not sure.

Any help at this point would be greatly appreciated.

3

In your module file app/etc/modules/Magentostudy_News.xml the line <Mage_adminhtml/> should be <Mage_Adminhtml/>

Notice the captial letter for Adminhtml.

You're telling Magento that your module depends on a module named Mage_adminhtml, Magento then tries to locate this but as it cant find it, it throws an Exception.

Welcome to Magento!

  • Thank you so much! I was actually wondering about that - I've already done a tutorial by Alan Storm, so I have a basic grasp of how to do things - I can set up a bare bones module and query the DB. It was kind of weird that Mage_adminhtml did not have the "a" as capital, but since I had never had anything to do with that module before, I followed the tutorial to the letter, which was obviously wrong. It's working now! Thanks for the welcome :) – Skytiger Mar 9 '16 at 15:19
  • 1
    Your Welcome, Alan Storm is great, stick to his tutorials and you'll soon be spotting these mistakes yourself, after all, sometimes you have to make a mistake to learn. Glad i could help you out. – JoshCarter Mar 9 '16 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.