如果在Magento的商店视图中处于活动状态,则链接到页面

时间:2015-11-20 12:48:09

标签: magento

如果页面在商店视图中处于活动状态但我没有工作,我会尝试添加指向cms页面的链接。如果页面仅对商店A有效,则会出现在商店B. Magento 1.9.1.1

<?php $active = Mage::getModel('cms/page')->setStoreId($storeId)->load('guia', $storeId)->getIsActive(); ?><?php if ($active == '1') : ?><a href="<?php echo $this->getUrl('guia');?>"><?php $aCmsPage = Mage::getModel('cms/page')->load('guia', 'identifier'); $theTitle = $aCmsPage->getTitle(); echo $theTitle; ?></a><?php endif; ?>

谢谢

1 个答案:

答案 0 :(得分:0)

<?php
$cmsCollections = Mage::getModel('cms/block')->getCollection();
$attribute = "identifier"; //name of column like Identifier, Title etc.
$value = "home-page-static"; // Value of attribute
$cmsCollections->addFieldToFilter($attribute, $value);
$item = $cmsCollections->getFirstItem();
$id = $item->getData('is_active');
if($id == 1){
    echo "CMS PAGE or Static Block Exists and Enable";
}else{
    echo "CMS PAGE or Static Block is in-active";
}
?>