I am working on a new extensions that stores some HTML data in Static blocks. To make it work as needed, I need to be able to add a new setting to the Static Block page that allows me to set a static block as enabled/disabled for my extension to use it.

My extension is named Bounce Reducer so that is the setting I would like to add.

Is this possible to add a setting to this screen like that? And then be able to access it in other sections/pages of my extensions code?


1 Answer 1


The enabled flag on static blocks correspond directly to the db table is_active column, which is of type smallint.

To enable this functionality in your own module, you'd have to extend that table and add a column onto the table cms_block (I use tinyint here, as a boolean):

    'br_enabled', 'tinyint(1) UNSIGNED DEFAULT 0 AFTER is_active');

You'll also have to rewrite Mage_Cms_Model_Resource_Block::_getLoadSelect to consider your flag as well:

protected function _getLoadSelect($field, $value, $object)
    $select = parent::_getLoadSelect($field, $value, $object);

    if ($object->getStoreId()) {
        $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
            array('cms_page_store' => $this->getTable('cms/page_store')),
            $this->getMainTable() . '.page_id = cms_page_store.page_id',
            ->where('is_active = ?', 1)
            ->where('br_enabled = ?', 1)
            ->where('cms_page_store.store_id IN (?)', $storeIds)
            ->order('cms_page_store.store_id DESC')

    return $select;

Finally, add in the appropriate form dropdown by extending Mage_Adminhtml_Block_Cms_Block_Edit_Form::_prepareForm and adding the following:

    $fieldset->addField('br_enabled', 'select', array(
        'label'     => Mage::helper('cms')->__('Bounce Reducer Enabled'),
        'title'     => Mage::helper('cms')->__('Bounce Reducer Enabled'),
        'name'      => 'br_enabled',
        'required'  => true,
        'options'   => array(
            '1' => Mage::helper('cms')->__('Enabled'),
            '0' => Mage::helper('cms')->__('Disabled'),
  • 1
    I am amazed again at your Magento knowledge. This is my first week in Magento land and it's kind of scary so far so I appreciate your help!
    – JasonDavis
    Jun 21, 2013 at 17:36
  • 1
    Thanks - Magento is a beast. I'm equally as amazed at how much I don't know compared to the gurus on here.
    – philwinkle
    Jun 21, 2013 at 22:01

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.