0

所以我正在构建一个自定义面包屑导航来列出所有筹款选项。这些页面使用了一个独特的布局,称为"fundraising_page."Is there a way to grab the pages only if they have the"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; ?>
4

2 回答 2

0

这是一些格式良好的代码并使用正确的方法。

<?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; ?>
于 2014-08-21T09:38:33.697 回答
0

而不是if($PageData['identifier']!='no-route')尝试

if($PageData['root_template']=='fundraising_page')
于 2014-08-21T01:03:13.153 回答