0

Tying to create a custom grid with the custom module but getting a blank page on grid page like below image. enter image description here

Here is my module name : Ds_Questions

app/code/local/Ds/Questions/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Ds_Questions>
            <version>1.0.1</version>
        </Ds_Questions>
    </modules>
    <frontend>
        <routers>
            <questions>
                <use>standard</use>
                <args>
                    <module>Ds_Questions</module>
                    <frontName>questions</frontName>
                </args>
            </questions>
        </routers>
        <layout>
            <updates>
                <questions>
                    <file>questions.xml</file>
                </questions>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <questions before="Mage_Adminhtml">Ds_Questions_Adminhtml</questions>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin> 
    <adminhtml>   
        <layout>
            <updates>
                <questions>
                    <file>questions.xml</file>
                </questions>
            </updates>
        </layout>
    </adminhtml>   
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Ds_Questions>
                        <title>Questions Module</title>
                        <sort_order>10</sort_order>
                        <children>
                            <items module="questions">
                                <title>Manage Question</title>
                                <sort_order>10</sort_order>
                                <action>adminhtml/questions</action>
                            </items>
                        </children>
                    </Ds_Questions>
                </children>
            </admin>
        </resources>
    </acl> 
    <global>
        <models>
            <questions>
                <class>Ds_Questions_Model</class>
                <resourceModel>questions_mysql4</resourceModel>
            </questions>
            <questions_mysql4>
                <class>Ds_Questions_Model_Mysql4</class>
                <entities>
                    <questions>
                        <table>questions</table>
                    </questions>
                </entities>
            </questions_mysql4>
        </models>
        <resources>
            <questions_setup>
                <setup>
                    <module>Ds_Questions</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </questions_setup>
            <questions_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </questions_write>
            <questions_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </questions_read>
        </resources>
        <blocks>
            <questions>
                <class>Ds_Questions_Block</class>
            </questions>
        </blocks>
        <helpers>
            <questions>
                <class>Ds_Questions_Helper</class>
            </questions>
        </helpers>
    </global>
</config>

app/code/local/Ds/Questions/etc/adminhtml.xml

<?xml version="1.0" ?>
<config>
    <menu>
        <questions module="questions">
            <title>Questions</title>
            <sort_order>71</sort_order>               
            <children>
                <items module="questions">
                    <title>Manage Question</title>
                    <sort_order>0</sort_order>
                    <action>adminhtml/questions</action>
                </items>
            </children>
        </questions>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <questions module="questions">
                        <title>questions</title>
                        <sort_order>100</sort_order>
                        <children>
                            <items module="questions">
                                <title>Manage Question</title>
                                <sort_order>10</sort_order>
                                <action>adminhtml/questions</action>
                            </items>
                        </children>
                    </questions>
                </children>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <questions translate="title" module="questions">
                                        <title>questions</title>
                                        <sort_order>100</sort_order>
                                    </questions>
                                </children>
                            </config>
                        </children>
                    </system>
                 </children>
            </admin>
        </resources>
    </acl>
</config>

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

<?xml version="1.0"?>
<layout version="1.0.1">
    <adminhtml_questions_index>
        <reference name="content">
            <block type="questions/adminhtml_questions" name="questions" />
        </reference>
    </adminhtml_questions_index>
</layout>

app/code/local/Ds/Questions/Block/Adminhtml/Questions.php

<?php
class Ds_Questions_Block_Adminhtml_Questions extends Mage_Adminhtml_Block_Widget_Grid_Container
{
  public function __construct()
  {
    die("hiiii");
    $this->_controller = 'adminhtml_questions';
    $this->_blockGroup = 'questions';
    $this->_headerText = Mage::helper('questions')->__('Questions List');
    $this->_addButtonLabel = Mage::helper('questions')->__('Add Question');
    parent::__construct();
  }
}

?>

app/code/local/Ds/Questions/Block/Adminhtml/Questions/Grid.php

<?php

class Ds_Questions_Block_Adminhtml_Questions_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
  public function __construct()
  {
      parent::__construct();
      $this->setId('questionsGrid');
      $this->setDefaultSort('question_id');
      $this->setDefaultDir('ASC');
      $this->setSaveParametersInSession(true);
  }

  protected function _prepareCollection()
  {
      $collection = Mage::getModel('questions/questions')->getCollection();
      $this->setCollection($collection);
      return parent::_prepareCollection();
  }

  protected function _prepareColumns()
  {
      $this->addColumn('question_id', array(
          'header'    => Mage::helper('questions')->__('ID'),
          'align'     =>'right',
          'width'     => '50px',
          'index'     => 'question_id',
      ));

      $this->addColumn('question', array(
          'header'    => Mage::helper('questions')->__('Question'),
          'align'     =>'left',
          'index'     => 'question',
      ));


      $this->addColumn('link', array(
      'header'    => Mage::helper('questions')->__('Link'),
      'width'     => '150px',
      'index'     => 'link',
      ));

      $this->addColumn('desc', array(
            'header'    => Mage::helper('questions')->__('Description'),
            'width'     => '150px',
            'index'     => 'desc',
      ));


      $this->addColumn('status', array(
          'header'    => Mage::helper('questions')->__('Status'),
          'align'     => 'left',
          'width'     => '80px',
          'index'     => 'status',
          'type'      => 'options',
          'options'   => array(
              1 => 'Enabled',
              2 => 'Disabled',
          ),
      ));

        $this->addColumn('action',
            array(
                'header'    =>  Mage::helper('questions')->__('Action'),
                'width'     => '100',
                'type'      => 'action',
                'getter'    => 'getId',
                'actions'   => array(
                    array(
                        'caption'   => Mage::helper('questions')->__('Edit'),
                        'url'       => array('base'=> '*/*/edit'),
                        'field'     => 'id'
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
                'is_system' => true,
        ));

        //$this->addExportType('*/*/exportCsv', Mage::helper('questions')->__('CSV'));
        //$this->addExportType('*/*/exportXml', Mage::helper('questions')->__('XML'));

      return parent::_prepareColumns();
  }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('question_id');
        $this->getMassactionBlock()->setFormFieldName('questions');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('questions')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('questions')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('questions/status')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('questions')->__('Change status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('questions')->__('Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }

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

}

app/code/local/Ds/Questions/Block/Adminhtml/Questions/Edit.php

<?php

class Ds_Questions_Block_Adminhtml_Questions_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
    {
        parent::__construct();

        $this->_objectId = 'id';
        $this->_blockGroup = 'questions';
        $this->_controller = 'adminhtml_questions';

        $this->_updateButton('save', 'label', Mage::helper('questions')->__('Save Question'));
        $this->_updateButton('delete', 'label', Mage::helper('questions')->__('Delete Question'));

        $this->_addButton('saveandcontinue', array(
            'label'     => Mage::helper('adminhtml')->__('Save And Continue Edit'),
            'onclick'   => 'saveAndContinueEdit()',
            'class'     => 'save',
        ), -100);

        $this->_formScripts[] = "
            function toggleEditor() {
                if (tinyMCE.getInstanceById('questions_content') == null) {
                    tinyMCE.execCommand('mceAddControl', false, 'questions_content');
                } else {
                    tinyMCE.execCommand('mceRemoveControl', false, 'questions_content');
                }
            }

            function saveAndContinueEdit(){
                editForm.submit($('edit_form').action+'back/edit/');
            }
        ";
    }

    public function getHeaderText()
    {
        if( Mage::registry('questions_data') && Mage::registry('questions_data')->getId() ) {
            return Mage::helper('questions')->__("Edit Question '%s'", $this->htmlEscape(Mage::registry('questions_data')->getTitle()));
        } else {
            return Mage::helper('questions')->__('Add Question');
        }
    }
}

and there are other files as well like Form.php and Tabs.php under folder app/code/local/Ds/Questions/Block/Adminhtml/Questions/Edit/

Although all file permission are set.

I can't figure out why admin layout file is not working.

Please advise.

  • Hi, do you have any error in logs ? (exception.log or server's php log ?) – Julien Loizelet Feb 21 '18 at 8:34
0

Please check if you have following files: app/etc/modules/Ds_Question.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Ds_Questions>
            <active>true</active>
            <codePool>local</codePool>
        </Ds_Questions>
    </modules>
</config>

app/code/local/Ds/Questions/Helper/Data.php

<?php

class Ds_Questions_Helper_Data extends Mage_Core_Helper_Abstract
{}

app/code/local/Ds/Questions/controllers/Adminhtml/QuestionsController.php

<?php

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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