0

So I'm building a custom breadcrumb nav to list all fundraising options. The pages are using a unique layout called "fundraising_page." Is there a way to grab the pages only if they have the "fundraising_page" layout? So far I have this, which is grabbing every page regardless of the template it is using.

So what I need is only to list the pages that are using the "fundraising_page" template.

<?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; ?>
TBI
  • 2,789
  • 1
  • 17
  • 21
Astrokotch
  • 35
  • 2

2 Answers2

0

Instead of if($PageData['identifier']!='no-route') try

if($PageData['root_template']=='fundraising_page')
subroutines
  • 1,458
  • 1
  • 12
  • 16
0

Here's some well formatted code and using proper methods.

<?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; ?>
xpoback
  • 265
  • 2
  • 7
  • Thanks man, worked like a charm! Any way to filter out the current page? So if you're on Fundraising Option 1, Fundraising Option 1 doesn't show in the menu? – Astrokotch Aug 21 '14 at 17:37
  • Use `Mage::getSingleton('cms/page')->getIdentifier()` - it returns current CMS page identifier. – xpoback Aug 22 '14 at 07:17