cancel
Showing results for 
Search instead for 
Did you mean: 

Display template in Admin Module of Magento

Display template in Admin Module of Magento

I am new in Magento. I am trying to develop a custom module for Magento Admin panel. My codes are as follows

 

Location : app/etc/modules

 

Digitab_Brandlogo.xml

 

 

<?xml version="1.0" encoding="utf-8"?>
<config>
     <modules>
        <Digitab_Brandlogo>
           <active>true</active>
           <codePool>local</codePool>
         </Digitab_Brandlogo>
     </modules>
</config>

 


Location : app/code/local/Digitab/Brandlogo/Block/Adminhtml

 

Brandlogo.php

 

 

<?php
class Digitab_Brandlogo_Block_Adminhtml_Brandlogo extends Mage_Adminhtml_Block_Widget_Grid_Container
{
  public function __construct()
  {
      $this->_controller = 'adminhtml_brandlogo';
      $this->_blockGroup = 'brandlogo';
      $this->_headerText = Mage::helper('brandlogo')->__('Brand Logo Manager');
      $this->_addButtonLabel = Mage::helper('brandlogo')->__('Add Brand');
      parent::__construct();
   }
}

 

 

Location: app/code/local/Digitab/Brandlogo/controllers/Adminhtml


BrandlogoController

 

 

<?php

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


location: app/code/local/Digitab/Brandlogo/etc

 

 

config.xml

 

 

<?xml version="1.0"?>
<config>
<modules>
<digitab_brandlogo>
<version>1.0.0</version>
</digitab_brandlogo>
</modules>
<global>
<models />
<blocks>
        <brandlogo>
            <class>Digitab_Brandlogo_Block</class>
         </brandlogo>
</blocks>
<resources />
<extraconfig />
         <helpers>
              <digitab_brandlogo>
                    <class>Digitab_Brandlogo_Helper</class>
              </digitab_brandlogo>
          </helpers>
</global>
<admin>
<routers>
      <digitab_brandlogo>
         <use>admin</use>
          <args>
               <module>Digitab_brandlogo</module>
               <frontName>brandlogo</frontName>
           </args>
     </digitab_brandlogo>
</routers>
</admin>
    <adminhtml>
      <layout>
       <updates>
         <brandlogo>
            <file>brandlogo.xml</file>
          </brandlogo>
         </updates>
       </layout>
     </adminhtml>
</config>

 

 

location: app/code/local/Digitab/Brandlogo/etc

 

adminhtml.xml

 

 

<?xml version="1.0"?>
<config>
<menu>
<digitab translate="title" module="digitab_brandlogo">
     <title>Digitab</title>
     <sort_order>110</sort_order>
     <children>
         <brandlogo>
              <title>Brand Logo</title>
              <sort_order>1</sort_order>
              <action>brandlogo/adminhtml_brandlogo</action>
         </brandlogo>
       </children>
</digitab>
</menu>
</config>


location: app/code/local/Digitab/Brandlogo/Helper

 

 

Data.php

 

 

<?php
class Digitab_Brandlogo_Helper_Data extends Mage_Core_Helper_Abstract
{
}

 

 

location: app/design/adminhtml/default/default/layout

 

brandlogo.xml

 

 

<?xml version="1.0"?> 
<layout version="0.1.0">
        <brandlogo_adminhtml_brandlogo_index>
          <reference name="content">
             <block type="brandlogo/adminhtml_brandlogo" name="brandlogo" template="test.phtml"/>
           </reference>
         </brandlogo_adminhtml_brandlogo_index> 
</layout>


location:app/design/adminhtml/default/default/template

 

 

test.phtml

 

 

ABCD 


But it is not working.  I can see only a blank white page in admin panel while I navigate to 'brandlogo' Menu . Can anyone help me in this regard??   Thanks

 

 

 

4 REPLIES 4

Re: Display template in Admin Module of Magento

Hello @foysal,

In the file: app\code\local\Digitab\Brandlogo\etc\adminhtml.xml you should change the code following:

<?xml version="1.0"?>
<config>
<menu>
<digitab translate="title" module="brandlogo">
     <title>Digitab</title>
     <sort_order>110</sort_order>
     <children>
         <brandlogo>
              <title>Brand Logo</title>
              <sort_order>1</sort_order>
              <action>brandlogo/adminhtml_brandlogo</action>
         </brandlogo>
       </children>
</digitab>
</menu>
</config>

Also, to enable developer mode in Magento, you can add the code below into index.php file:

Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);

Hope you success!

www.advancedcheckout.com - www.stableaddon.com
One Step checkout extension - Social Login extension - Gift Card extension

Re: Display template in Admin Module of Magento

@ACheckout thanks for your reply. But it is not working. Thanks 

Re: Display template in Admin Module of Magento

@foysal try change config.xml following:

<config>
    <modules>
        <Digitab_Brandlogo>
            <version>0.1.0</version>
        </Digitab_Brandlogo>
    </modules>
    <frontend>
        <routers>
            <brandlogo>
                <use>standard</use>
                <args>
                    <module>Digitab_Brandlogo</module>
                    <frontName>brandlogo</frontName>
                </args>
            </brandlogo>
        </routers>
        <layout>
            <updates>
                <brandlogo>
                    <file>brandlogo.xml</file>
                </brandlogo>
            </updates>
        </layout>
        <translate>
            <modules>
                <Digitab_Brandlogo>
                    <files>
                        <default>Digitab_Brandlogo.csv</default>
                    </files>
                </Digitab_Brandlogo>
            </modules>
        </translate>
    </frontend>
    <admin>
        <routers>
            <brandlogoadmin>
                <use>admin</use>
                <args>
                    <module>Digitab_Brandlogo</module>
                    <frontName>brandlogoadmin</frontName>
                </args>
            </brandlogoadmin>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <brandlogo>
                    <file>brandlogo.xml</file>
                </brandlogo>
            </updates>
        </layout>
        <translate>
            <modules>
                <Digitab_Brandlogo>
                    <files>
                        <default>Digitab_Brandlogo.csv</default>
                    </files>
                </Digitab_Brandlogo>
            </modules>
        </translate>
    </adminhtml>   
    <global>
        <models>
            <brandlogo>
                <class>Digitab_Brandlogo_Model</class>
                <resourceModel>brandlogo_mysql4</resourceModel>
            </brandlogo>
            <brandlogo_mysql4>
                <class>Digitab_Brandlogo_Model_Mysql4</class>
                <entities>
                    <brandlogo>
                        <table>brandlogo</table>
                    </brandlogo>
                </entities>
            </brandlogo_mysql4>
        </models>
        <resources>
            <brandlogo_setup>
                <setup>
                    <module>Digitab_Brandlogo</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </brandlogo_setup>
            <brandlogo_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </brandlogo_write>
            <brandlogo_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </brandlogo_read>
        </resources>
        <blocks>
            <brandlogo>
                <class>Digitab_Brandlogo_Block</class>
            </brandlogo>
        </blocks>
        <helpers>
            <brandlogo>
                <class>Digitab_Brandlogo_Helper</class>
            </brandlogo>
        </helpers>        
    </global>
</config>
www.advancedcheckout.com - www.stableaddon.com
One Step checkout extension - Social Login extension - Gift Card extension

Re: Display template in Admin Module of Magento

Hello foysal,

 

You made some mistakes:

 

+Your Helper wrong

For example in: app/code/local/Digitab/Brandlogo/Block/Adminhtml/Brandlogo.php

Mage::helper('brandlogo') => should be Mage::helper('digitab_brandlogo') because in your config.xml , you declared:

<helpers>
    <digitab_brandlogo>
       <class>Digitab_Brandlogo_Helper</class>
   </digitab_brandlogo>
</helpers>

+SUPEE 6788 => router + admin menu
You update the security path SUPEE 6788? You must update this path for your site. Read more here:
https://magento.com/security/patches/supee-6788-technical-details
=> admin router should be change to:

 <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <digitab_brandlogo after="Mage_Adminhtml">Digitab_Brandlogo_Adminhtml</digitab_brandlogo>
                    </modules>
                </args>
            </adminhtml>
        </routers>
</admin>


The link in Admin menu should be:

<children>
                <brandlogo>
                    <title>Brand Logo</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/brandlogo</action>
                </brandlogo>
</children>

 

+ Your layout and Block
You want to create a grid container? This will be more complicated than only show a text message. You must create Magento Grid: Grid Container, Grid Block, Widget Form Container, Form Block. I had done a series about this. You can read more:
http://www.boolfly.com/magento-brand-extension-part-1/
http://www.boolfly.com/magento-brand-extension-part-2/
http://www.boolfly.com/magento-brand-extension-part-3/

For showing a simple text message, your block should extends from Mage_Adminhtml_Block_Template

#app/code/local/Digitab/Brandlogo/Block/Adminhtml/Brandlogo.php

class Digitab_Brandlogo_Block_Adminhtml_Brandlogo extends Mage_Adminhtml_Block_Template
{
    public function _construct()
    {
        parent::_construct();
        //Set template or create block here
        //$this->setTemplate('test.phtml');

    }
}


In your xml layout: app/design/adminhtml/default/default/layout/brandlogo.xml
<brandlogo_adminhtml_brandlogo_index> => <adminhtml_brandlogo_index>

 

Note: I tested your code lines on Magento 1.9.2.2 with SUPEE 6788. You can download code from my Dropbox: https://www.dropbox.com/sh/5ygsx4hhhcxh78k/AADAZ-WMRUZ9m-lrosy4Z7jpa?dl=0

Problem solved? Click Accept as Solution!