3

I have followed a wiki post to setup a custom module with a custom database table.

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table

One thing that I can't work out is how to display a list of database entries in the admin backend. Any ideas about what I'm missing would be greatly appreciated?

2 Answers 2

1

Below Code is simple method to view your custom table datas in admin panel

Admin view for your custom module :

Create the below path in your module :

/app/code/local/<Namespace>/<Module>/etc/adminhtml.xml

in adminhtml.xml file contain below content

<?xml version="1.0"?>
<config>
    <menu>
        <[module] module="[module]">
            <title>[Module]</title>
            <sort_order>71</sort_order>               
            <children>
                <items module="[module]">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>[module]/adminhtml_[module]</action>
                </items>
            </children>
        </[module]>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <[module]>
                        <title>[Module] Module</title>
                        <sort_order>200</sort_order>
                    </[module]>
                </children>
            </admin>
        </resources>   
    </acl>
    <layout>
        <updates>

Create the Adminhtml folder and create Controller.php file

/app/code/local/<Namespace>/<Module>/controllers/Adminhtml/<Module>Controller.php

in <Module>Controller.php file contain below content

<?php 
class <Namespace>_<module>_Adminhtml_<module>Controller extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
            $this->loadLayout()->_setActiveMenu('<module>/items');
            $this->renderLayout();

    }   

}

app/design/adminhtml/default/default/layout/.xml

in <module>.xml file contain below content

<?xml version="1.0"?>
<layout version="0.1.0">
    <[module]_adminhtml_[module]_index>
        <reference name="content">
            <block type="core/template" name="domain" template="[module]/[module].phtml"/>
        </reference>
    </[module]_adminhtml_[module]_index>
</layout>

Create the new folder in below path

app/design/adminhtml/default/default/template/<module>/<module>.phtml

in <module>.phtml file contain below content

<?php

// Write your custom table Collection Here

?>
Sign up to request clarification or add additional context in comments.

6 Comments

Great responses! Managed to find issue whereby I had to add '$this->_addContent($this->getLayout()->createBlock('[module]/adminhtml_[module]'));' to the IndexController and remove that same line from [Module]Controller. Tried viewing the module on the frontend with no luck. Have tried 'magento.domain.local/module' and 'magento.domain.local/module/index/index'. Keep getting 'HTTP Error 500 (Internal Server Error)'. Any ideas?
Please try to view your module url look like domain_name.com/module_name/controller_name/action_name
if you get 500 internal server error, Modify your memory_limit to minimum 128M in your php.ini file..
tried module url & memory limit is set to 128M - no luck so far
the above example is missing router section in config.xml
|
1

Well, to display database entries in the admin backend, you'll need to do the following things: - Create a router for admin backend controller. THis can be done via the config.xml file - Create a controller - Create a grid container block - Create a grid block. In this Grid block, you can specify which columns... you want to add to the list

You can follow the following tutorials:

  1. http://markshust.com/2012/07/05/creating-magento-adminhtml-grids-simplified
  2. http://www.webspeaks.in/2010/08/create-admin-backend-module-in-magento.html

Magento admin is quite complex, the best way to learn it is to look at the existing code such as how Magento display product list...

Comments

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.