1

I have created Admin Controller,When I hit on menu it's showing empty page.

Why it's not showing? Can any one tell me?

my code is:

College->Svccs->etc->config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <College_Svccs>
            <version>0.0.1</version>
        </College_Svccs>
    </modules>
    <frontend>
        <routers>
            <svccs>
                <use>standard</use>
                <args>
                    <module>College_Svccs</module>
                    <frontName>svccs</frontName>
                </args>
            </svccs>
        </routers>
        <layout>
            <updates>
                <svccs>
                    <file>svccs.xml</file>
                </svccs>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <svccs>
                <use>admin</use>
                <args>
                    <module>College_Svccs</module>
                    <frontName>svccs</frontName>
                </args>
            </svccs>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <svccs module="svccs">
                <title>Svccs Branches</title>
                <sort_order>88</sort_order>
                <children>
                    <svcet module="svccs">
                        <title>Svcet</title>
                        <sort_order>0</sort_order>
                        <action>svccs/adminhtml_index</action>
                    </svcet>
                </children>
            </svccs>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <College_Svccs>
                            <title>Svccs Branches Module</title>
                            <sort_order>88</sort_order>
                        </College_Svccs>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <svccs>
                    <file>svccs.xml</file>
                </svccs>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <models>
            <svccs>
                <class>College_Svccs_Model</class>
                <resourceModel>svccs_resource</resourceModel>
            </svccs>
            <svccs_resource>
                <class>College_Svccs_Model_Resource</class>
                <entities>
                    <svccs>
                        <table>svccs</table>
                    </svccs>
                </entities>
            </svccs_resource>
        </models>
        <resources>
            <svccs_setup>
                <setup>
                    <module>College_Svccs</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </svccs_setup>
            <svccs_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </svccs_read>
            <svccs_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </svccs_write>
        </resources>
        <blocks>
            <svccs>
                <class>College_Svccs_Block</class>
            </svccs>
        </blocks>
        <helpers>
            <svccs>
                <class>College_Svccs_Helper</class>
            </svccs>
        </helpers>
    </global>

</config>

College->Svccs->Block->Adminhtml->Grid.php

<?php

class College_Svccs_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function _construct()
    {
        //where is the controller
        $this->_controller = 'adminhtml_svccs';
        $this->_blockGroup = 'svccs';
        //text in the admin header
        $this->_headerText = 'Svccs Department';
        //value of the add button
        $this->_addButtonLabel = 'Add Svccs College';
        parent::__construct();
    }
}

College->Svccs->Block->Adminhtml->Svccs->Gird.php

<?php

class College_Svccs_Block_Adminhtml_Svccs_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('svccsGrid');
        $this->setDefaultSort('college_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
    }

    protected function _prepareCollection()
    {

        $collection = Mage::getModel('svccs/svccs')->getCollection();
        Mage::log((array)$collection);
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        $this->addColumn('college_id',
            array(
                'header' => 'Test ID',
                'align'  =>'right',
                'width'  => '50px',
                'index'  => 'college_id',
            ));
        $this->addColumn('collegename',
            array(
                'header' => 'College Name',
                'align'  =>'left',
                'index'  => 'collegename',
            ));
       $this->addColumn('telephone', array(
            'header' => 'Telephone',
            'align'  =>'left',
            'index'  => 'telephone',
        ));
        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

}

College->Svccs->controllers->Adminhtml->IndexController.php

<?php

class College_Svccs_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

adminhtml->default->College->Svccs->layout->svccs.xml

  <?xml version="1.0"?>
    <layout version="0.1.0">
        <svccs_adminhtml_index_index>
            <reference name="content">
                <block name="svccs_svccs" type="svccs/adminhtml_grid" ></block>
            </reference>
        </svccs_adminhtml_index_index>
    </layout>
6
  • have you put some debug into the indexAction to make sure that you are getting this far? Commented Oct 28, 2013 at 10:19
  • @DavidManners, I configure the debug in indexAction it's working, but when I configure the debut in Grid.php file it's not working? I think Layout file is not calling! Can you suggest me. Commented Oct 28, 2013 at 11:49
  • check that $this->getLayout()->getUpdate()->getHandles() includes the layout handle that you have in your xml Commented Oct 28, 2013 at 12:25
  • @DavidManners, where I write this? Commented Oct 28, 2013 at 12:39
  • in the controller action after loadlayout. make sure you log it or var_dump so you can see the output Commented Oct 28, 2013 at 12:40

1 Answer 1

1

You've called your controller '$this->_controller = 'adminhtml_svccs';' but the filename seems to be controller/Adminhtml/IndexController.php while it should be controller/Adminhtml/SvccsController.php.

2
  • I change the $this->_controller = 'adminhtml_svccs' to $this->_controller = 'adminhtml_index', still it's showing empty page. Commented Oct 28, 2013 at 10:58
  • Hi Peter, I configure the debug in indexAction it's working, but when I configure the debut in Grid.php file it's not working? I think Layout file is not calling! Can you suggest me? Commented Oct 28, 2013 at 11:50

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.