0

I have created a Magento admin module with it's own menu and page in the back-end, and am trying to recreate how CMS->Pages lists every page in it's grid on my own page, then add my own column.

So far, after switching on template hints for the admin section, I have seen that the original Magento CMS section template is loaded from adminhtml\default\default\template\widget/grid.phtml.

I have copied the contents of this file to my page, but of course, the $this reference that the original uses doesn't have the same loaded classes/data asociated with it on my own module page.

Can anyone tell me if I'm along the right lines with this, or how I might achieve the same effect as CMS->Pages, but on my own page and adding my own column?

Gga
  • 4,311
  • 14
  • 39
  • 74
  • Are you trying to create a grid with your custom module table info or are you trying to create a grid that display cms page related info? – MagePal Extensions Oct 31 '12 at 15:52
  • @R.S CMS page related info. I'd essentially like just like a mirror of the existing but with one additional column... – Gga Oct 31 '12 at 16:28

1 Answers1

1

To accomplish this you can create a custom module that extend /app/code/core/Mage/Adminhtml/Block/Cms/Block/Grid.php

Assuming that you're adding a database field to cms table

Create /app/code/local/RWS/CmsGrid/etc/config.xml

<global>
   <blocks>
      <adminhtml>
        <rewrite>
          <cms_block_grid>RWS_CmsGrid_Block_Cms_Block_Grid</cms_block_grid>
        </rewrite>
      </adminhtml>
   </blocks>
</global>

Create /app/code/local/RWS/CmsGrid/Block/Cms/Block/Grid.php

class RWS_CmsGrid_Block_Cms_Block_Grid extends Mage_Adminhtml_Block_Cms_Block_Grid
{

   protected function _prepareColumns()
   {

      $this->addColumn('xxxxxx', array(
          'header'    => Mage::helper('cms')->__('Xxxxx'),
          'align'     => 'left',
          'index'     => 'title',
     ));
     ..........

See more info

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62
  • Thanks for your answer, will this add a new field to the existing CMS->Pages or create a duplicate version of CMS->Pages on my own module page? as the latter is what I require, cheers. – Gga Nov 01 '12 at 10:11
  • Have further tested and it works really well, so thanks again. – Gga Nov 01 '12 at 10:22