0

Another issue with building my admin module!! I can't get the page to show! Already have the page and drop down links showing without errors like I had last week. Now I can't get my template page to show up. What am I doing wrong with declaring these blocks?

Config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Caitlinhavener_Addschool>
            <version>0.1.0</version>
        </Caitlinhavener_Addschool>
    </modules> 

    <global>
        <blocks> 
            <addschoolblock1>
                <class>Caitlinhavener_Addschool_Block</class>
            </addschoolblock1> 
        </blocks>
        <helpers>
            <addschool>
                <class>Caitlinhavener_Addschool_Helper</class>
            </addschool>
        </helpers>  
    </global>    

    <admin>
        <routers>
           <adminhtml>
                <use>admin</use>
                <args>
                    <modules>
                        <Caitlinhavener_Addschool after="Mage_Adminhtml">Caitlinhavener_Addschool</Caitlinhavener_Addschool>
                    </modules>
                </args>
           </adminhtml>          
        </routers>      
    </admin> 
</config>

adminhtml.xml:

<?xml version="1.0"?>
<config>
    <menu>
        <SchoolMenu translate="title" module="addschool">
            <title>Schools</title>
            <sort_order>23</sort_order>
            <children>
                <myitem2 translate="title" module="addschool">
                        <title>Add Schools</title>
                        <action>adminhtml/addschool</action>
                        <sort_order>2</sort_order>                        
                </myitem2>
            </children>
        </SchoolMenu>
    </menu>
</config>

controllers/Addschoolcontroller.php:

<?php

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

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


        $this->renderLayout();
    }
}

Block/ShowTabsAdminBlock.php:

<?php

class Caitlinhavener_Addschool_Block_ShowTabsAdminBlock extends Mage_Adminhtml_Block_Widget_Tabs
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('add_school');
        $this->setTitle(Mage::helper('addschool')->__('Add Schools'));
    }

    protected function _beforeToHtml()
    {

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

        return parent::_beforeToHtml();
    }  
}

Block/SampleBlockForTabAreaShowoffWithExtraInfo.php:

<?php

class Caitlinhavener_Addschool_Block_SampleBlockForTabAreaShowoffWithExtraInfo extends Mage_Adminhtml_Block_Template
{

    public function __construct()
    {       
        parent::__construct();
        $this->setTemplate('Caitlinhavener/sample_for_tab_container.phtml');       
    }    
}
2
  • What is the magento-relative template path?
    – benmarks
    Aug 12, 2013 at 20:07
  • /app/design/adminhtml/default/default/template/Caitlinhavener Aug 12, 2013 at 20:36

1 Answer 1

2

You should use a generator. It will save you a ton of time.

http://www.silksoftware.com/magento-module-creator

That will generate the base of the extension for you so it should work right out of the gate, then you can add what you want and go from there.

3
  • Awesome! Can I put my entire template html into that "Backend Page Content"? Aug 12, 2013 at 21:24
  • I dont see why not but I havent really pushed it to see. I just generate the name and a few options and then I do the rest by hand. I use it just to save time generating the naming scheme and stuff like that. Give it a shot and tell me if it lets you paste in all your html and renders ok. Aug 12, 2013 at 21:41
  • For your reference, yes you can paste in all the code for the template :) Aug 20, 2013 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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