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):
$installer->getConnection()->addColumn($installer->getTable('cms/block'),
'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());
$select->join(
array('cms_page_store' => $this->getTable('cms/page_store')),
$this->getMainTable() . '.page_id = cms_page_store.page_id',
array())
->where('is_active = ?', 1)
->where('br_enabled = ?', 1)
->where('cms_page_store.store_id IN (?)', $storeIds)
->order('cms_page_store.store_id DESC')
->limit(1);
}
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'),
),
));
Try to put this in a new file say footer_categories.phtml
:
<div class="footer_categories">
<ul>
<?php $helper = $this->helper('catalog/category') ?>
<?php foreach ($helper->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a>
</li>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml() ?>
Now open your static block and call in this way
{{block type="core/template" template="catalog/footer_categories.phtml"}}
you can get the required output.
Best Answer
Login to admin panel Click on CMS > Static Blocks.
Create New Block suppose Identifier = block_test
Add Content :
For testing Create CMS page and call CMS block from CMS page
suppose URL Key = test
Add Content :
Go to front end /test and click on "here" link, alert message will popup.