Magento – Fix 404 Errors on Index and Magento Connect Pages Caused by Module

module

I am getting a 404 message within the body of the index and magento connect admin pages. When I remove the module that I recently added, they come back. Can you see what is wrong with my module that is causing this issue? I got the files from this tutorial.

Caitlinhavenerr/Addschool/Block/ShowTabsAdminBlock.php:

<?php

class Caitlinhavener_Addschool_Block_ShowTabsAdminBlock extends Mage_Adminhtml_Block_Widget_Tabs
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('my_custom_freely_assigned_id_for_tabs');

        /*
         * By default DestElementId = 'content'... if you trace the function you will see.
         * Meaning, it responds to layout block name?! like "content", "footer", "left"... 
         * Its basicaly telling the layout where to output tabs canvas aka display area
         */
        //$this->setDestElementId('my_custom_edit_form');

        $this->setTitle(Mage::helper('coffefreakhelper1')->__('Add Schools'));
    }

    protected function _beforeToHtml()
    {
       /* $this->addTab('custom_assigned_tab1_id_name', array(
            'label'     => Mage::helper('coffefreakhelper1')->__('Custom tab1 here'),
            'title'     => Mage::helper('coffefreakhelper1')->__('My custom tab1 title here'),
            'content'   => 'Some content here. We could add direct string here, or we can use something like $this->getLayout()->createBlock("adminhtml/cms_page_edit_tab_main")->toHtml()',
            'active'    => true
        ));

        $this->addTab('custom_aka_freely_assigned_tab2_id_name', array(
            'label'     => Mage::helper('coffefreakhelper1')->__('Custom tab2 here'),
            'title'     => Mage::helper('coffefreakhelper1')->__('My custom tab2 title here'),
            'content'   => 'Another content here. As mentioned, we could add direct string here, or we can use something like $this->getLayout()->createBlock("adminhtml/cms_page_edit_tab_main")->toHtml()',
            'active'    => false
        ));

        $this->addTab('custom_aka_freely_assigned_tab3_id_name', array(
            'label'     => Mage::helper('coffefreakhelper1')->__('Custom tab3 here<br />(usses class block)'),
            'title'     => Mage::helper('coffefreakhelper1')->__('My custom tab3 title here'),
            'content'   => $this->getLayout()->createBlock("coffefreakblock2/SampleBlockForTabAreaShowoff")->toHtml(),
            'active'    => false
        ));  */  

        $this->addTab('custom_aka_freely_assigned_tab4_id_name', array(
            'label'     => Mage::helper('coffefreakhelper1')->__('Add Public School'),
            'title'     => Mage::helper('coffefreakhelper1')->__('Add Public School'),
            'content'   => $this->getLayout()->createBlock("coffefreakblock1/SampleBlockForTabAreaShowoffWithExtraInfo")->toHtml(),
            'active'    => false
        ));          

        return parent::_beforeToHtml();
    }  
}

controllers/AdminControllersHere/FreakOutController.php:

<?php

class Caitlinhavener_Addschool_AdminControllersHere_FreakOutController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        //Get current layout state
        $this->loadLayout();

        //Create core block based on inchoo/example_core_block.phtml template (view) file
        //Note the location "adminhtml"... needs to be there since this is admin controller
        $block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'my_block_name_here',
            array('template' => 'Caitlinhavener/example_core_block.phtml')
        );




        $this->getLayout()->getBlock('content')->append($block);
        //Below example does the same thing, and looks cooler :)
        //$this->_addContent($block);

        //Release layout stream... lol... sounds fancy
        $this->renderLayout();
    }
}

same folder FreakOutController2.php:

<?php

class Caitlinhavener_Addschool_AdminControllersHere_FreakOut2Controller extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();

        $block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'my_block_name_here',
            array('template' => 'Caitlinhavener/example_core_block.phtml')
        );

        //$this->_addContent($block);

        $this->_addLeft($this->getLayout()->createBlock('Caitlinhavener_Addschool_Block_ShowTabsAdminBlock'));

        $this->renderLayout();
    }
}

config.xml:

<?xml version="1.0"?>

<config>
    <modules>
        <Caitlinhavener_Addschool>
            <version>0.1.0</version>
        </Caitlinhavener_Addschool>
    </modules> 

    <global>
        <blocks>
            <coffefreakblock1>
                <class>Caitlinhavener_Addschool_Block</class>
            </coffefreakblock1>  
            <coffefreakblock2>
                <class>Caitlinhavener_Addschool_Block_EditSpecial</class>
            </coffefreakblock2> 
        </blocks>
        <helpers>
            <coffefreakhelper1>
                <class>Caitlinhavener_Addschool_Helper</class>
            </coffefreakhelper1>
        </helpers>  
    </global>    






    <admin>
        <routers>

           <samplerouter1>
                <use>admin</use>
                <args>
                    <module>Caitlinhavener_Addschool_AdminControllersHere</module>
                    <frontName>admin</frontName>

                    <modules>
                        <sintax after="Caitlinhavener_Addschool_AdminControllersHere">Mage_Adminhtml</sintax>
                    </modules>
                </args>
           </samplerouter1>          



         </routers>     
    </admin>





    <adminhtml>


        <menu>
             <mymenu1 translate="title" module="coffefreakhelper1">
                <title>Schools</title>
                <sort_order>20</sort_order>
                <children>
                <!-- Note the misleading "module" attribute. 
                    It actualy refers to one of the declared helpers -->

                    <!--<myitem1 translate="title" module="coffefreakhelper1">
                        <title>Simple one column layout with custom template file assigned for view</title>
                        <action>samplerouter1/FreakOut</action>
                        <sort_order>1</sort_order>                        
                    </myitem1>-->

                    <myitem2 translate="title" module="coffefreakhelper1">
                        <title>Add Schools</title>
                        <action>samplerouter1/FreakOut2</action>
                        <sort_order>2</sort_order>                        
                    </myitem2>                    


                </children>
             </mymenu1>
        </menu>
    </adminhtml>    

</config>

Best Answer

Your <routers> configuration is incorrect. As guessed at, your configuration is telling Magento to use your module as a place to look for admin controllers. When it can't find them, it gets sad.

Specifically,

  • <samplerouter1/> should be <adminhtml/>
  • Remove the <module>Caitlinhavener_Addschool_AdminControllersHere</module> tag, it's not needed
  • Remove the <frontName>admin</frontName> tag, it's not needed

More information at

Related Topic