因此,我正在构建一个自定义面包屑导航,以列出所有筹款选项。页面使用唯一的布局,称为“"fundraising_page."
是否有办法仅当页面具有它们时才抓取页面” "fundraising_page" layout?
。到目前为止,我正在抓取每个页面,而不管其使用的模板是什么。
因此,我只需要列出使用"fundraising_page"
模板的页面即可。
<?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
<?php $collection->getSelect()->where('is_active = 1'); ?>
<ul>
<?php foreach ($collection as $page): ?>
<?php $PageData = $page->getData(); ?>
<?php if($PageData['identifier']!='no-route'){ ?>
<li>
<a href="/<?php echo $PageData['identifier']?>"><?php echo $PageData['title'] ?></a>
</li>
<?php } ?>
<?php endforeach; ?>
这是一些格式正确的代码,并使用适当的方法。
<?php
$collection = Mage::getModel('cms/page')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addFieldToFilter('is_active', 1)
->addFieldToFilter('root_template', 'fundraising_page');
?>
<?php foreach ($collection as $page): ?>
<?php if ($page->getIdentifier() != 'no-route'): ?>
<li>
<a href="<?php echo Mage::getUrl($page->getIdentifier())?>"><?php echo $page->getTitle() ?></a>
</li>
<?php endif; ?>
<?php endforeach; ?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句