Check Static Block Is Active on Store View

1.2k Views Asked by At

I have this static block which appears in navigation bar if enabled. I want it to appear only when it’s enabled for selected store view (and remains disabled on other store views).

My thought is just to check whether it’s active and enabled in current store view, but I can’t find documentation or tutorial that points to it.

Any ideas or references I can use?

<?php  $custom_tab = Mage::getModel('cms/block')->load('vista_navigation_block');
            if($custom_tab->getIsActive()) {
            echo '
            <li class="nav-custom-link level0 level-top parent">
                <a href="#" class="level-top">
                    <span>'.$custom_tab->getTitle().'</span>
                </a>
                <div class="level0-wrapper" style="left: 0px; display: none;"><div class="header-nav-dropdown-wrapper clearer">'.$this->getLayout()->createBlock('cms/block')->setBlockId('vista_navigation_block')->toHtml().'</div></div>
            </li>';
          }  ?>

            </ul> <!--nav-->

    <?php endif; ?>
1

There are 1 best solutions below

1
On

Try the below code,

    $storeId = Mage::app()->getStore()->getId();
    $identifierName = 'identifier-name';
    $staticBlock= Mage::getModel('cms/block')->getCollection()->addStoreFilter($storeId)->addFieldToFilter('identifier',array('like'=>$identifierName))->getFirstItem();
    $isActive =  $staticBlock->getIsActive()