In Magento 1.9.2.1 I would like to show all the categories on a normal page. And I am almost there, but I can't get loading the image and description to work.
This is the page: http://www.cameradraagcomfort.nl/categorie-overzicht/
Here is the PHP I used:
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php if (count($_categories) > 0): ?>
<div class="categorieListing">
<?php foreach ($_categories as $_category): ?>
<div class="span-1-3">
<h3><?php echo $_category->getName() ?></h3>
<div class="Collimg">
<a title="<?php echo $_category->getName() ?>" href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php $imageUrl = $_category->getImageUrl() ?>
<?php if (!empty($imageUrl)) { ?>
<img class="sub-image" src="<?php echo $imageUrl ?>" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" />
<?php } else { ?>
<img src="<?php echo $this->getSkinUrl('images/media/collections/maddogsandenglishmen.jpg'); ?>" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" />
<?php } ?>
</a>
<div class="toggletext">
<p><?php echo $_category->getDescription() ?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
Finally some results... The code below is the solution. The rest of the code is the same.
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect(array('name', 'image', 'description', 'overzicht'))
->addAttributeToFilter('overzicht', 1)
->addAttributeToSort('position'); ?>