0

When I try to load my custom grid view in the admin page, I got a blank page with the default admin layout loaded in instead of my grid. I tried many things but I can't find the bug.

My controller is implemented as follows:

<?php
class Brain2Terminal_CertWizard_Adminhtml_CertinfoController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction() {
        $this->loadLayout(); 
        $this->_setActiveMenu('sales/sales');
        $this->_addContent($this->getLayout()->createBlock('CertWizard/adminhtml_certinfo'));

        $this->renderLayout();
    }   
}

Grid container:

<?php
class Brain2Terminal_CertWizard_Block_Adminhtml_Certinfo extends
Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {   
        parent::__construct();
        $this->_controller = "adminhtml_certinfo";
        $this->_blockGroup = "CertWizard";
        $this->_headerText = Mage::helper ( 'flexibleforms' )->__ ( 'Manage Infos' );
        $this->_addButtonLabel = Mage::helper ( 'CertWizard' )->__ ( 'Add Info' );  
    }

    protected function _prepareLayout()
    {
        $this->setChild( 'grid', $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid', $this->_controller . '.grid')->setSaveParametersInSession(true) );
        return parent::_prepareLayout();
    }
}

The Grid:

<?php
class Brain2Terminal_CertWizard_Block_Adminhtml_Certinfo_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId("certinfoGrid");
        $this->setDefaultSort("id");
        $this->setDefaultDir("ASC");
        $this->setUseAjax(true);
        $this->setSaveParametersInSession(true);
    }


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

    protected function _prepareColumns()
    {
        $this->addColumn("id", array(
            "header" => $this->__("ID"),
            "align" => "right",
            "width" => "30px",
            "type" => "number",
            "index" => "id",
        ));
        $this->addColumn("attributeset_id", array(
            "header" => $this->__("Attributeset"),
            "align" => "right",
            "width" => "50px",
            "type" => "varchar",
            "index" => "attributeset_id",
        ));
        $this->addColumn("info", array(
            "header" => $this->__("Info"),
            "align" => "right",
            "width" => "50px",
            "type" => "varchar",
            "index" => "info",
        ));

        return parent::_prepareColumns();
    }
}

If any more information is needed, please let me know.


So my layout.xml file looks like follows:

 <layout>
 <adminhtml_certinfo_index>
    <reference name="content">
        <block type="CertWizard/adminhtml_certinfo" name="certinfo" />
    </reference>
</adminhtml_certinfo_index>
</layout>

Like you said i added a node with prefixing adminhtml_ in addition i refer to the correct block. When i debug everything is fine and block is also called without problems. Certainly i'm getting no gridview. Why?

Once again I've debugged the part where the the controller loads the layout and put the method

        var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    die();

after loadLayout().

The result was

    array (size=4)
  0 => string 'default' (length=7)
  1 => string 'STORE_admin' (length=11)
  2 => string 'THEME_adminhtml_default_MAG100207_MobileStore/' (length=46)
  3 => string 'adminhtml_certinfo_index' (length=24)

But still I can't find the bug.

6
  • A blank page results from a PHP error. Knowing, what the error message is would help a lot. Please see magento.stackexchange.com/questions/428/… for infos about error logging and debugging in general Commented Sep 9, 2016 at 13:59
  • I know how to display errors in magento. But no one is shown. Otherwise I wouldn't ask for your help. Commented Sep 9, 2016 at 15:26
  • so you did check the PHP error logs? (not the Magento error logs, they don't show you fatal errors). And the page is really blank (i.e. white page, no HTML at all)? Commented Sep 9, 2016 at 15:29
  • I'm getting the magento backend layout without content. So only the grid isn't showing up in mycase Commented Sep 9, 2016 at 15:59
  • See, that's important information. Commented Sep 9, 2016 at 15:59

1 Answer 1

1

Initially, I read the question as saying that you didn't see anything on the screen.

If you see a completely blank screen:

In Magento, when a blank page is displayed with no error warning, it's typically symptomatic of a PHP error, usually related to improper syntax. I'd try uploading the files to an online PHP linter to ensure that the basic syntax is correct, and fix any errors.

If your grid is not showing, but the rest of the Magento admin layout is:

The issue is likely related to layout XML. You probably aren't assigning the blocks to the correct controller handle (remember that admin handles are usually all prefixed with adminhtml_*, like adminhtml_sales_order_view), or the container block doesn't have the grid block associated with it properly (usually done in the container's _prepareLayout() method), or some other layout-related issue. Maybe the grid container isn't assigned to the handle at all.

You're seeing the Magento admin layout, so the issue is more likely related to my second point. In your specific case, your _prepareLayout() method looks fine, so I'd look in the layout XML file next.

1
  • Could you help me, please. Commented Sep 14, 2016 at 13:52

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.