I have trouble creating a foreach request data from an array.
Example to request Name, URL and Image from Magento:
<?php
$cat_id = array(268, 269, 270, 271, 272, 273, 274, 275, 276);
$helper = Mage::helper('catalog/category');
?>
<div class="main">
<?php foreach ($cat_id as $id):?>
<div class="category">
<a href="<?php echo $helper->getCategoryUrl($id); ?>">
<img src="<?php echo $helper->getThumbnailUrl($id); ?>" title="<?php echo $helper->getName($id); ?>"/>
<div class="text"><h2><?php echo $helper->getName($id); ?></h2></div>
</a>
</div>
<?php endforeach; ?>
</div>
The issue is that i can figure out nothing, and no errors giving, i really appreciate if can someone tell me what is wrong ?
Solution provided by Vladimir Boliev:
<?php
$cat_id = array(268, 269, 270, 271, 272, 273, 274, 275, 276);
?>
<div class="main">
<?php foreach ($cat_id as $id):?>
<?php $cur_category = Mage::getModel('catalog/category')->load($id);
$url = $cur_category->getUrl();
$name = $cur_category->getName();
$img = $cur_category->getThumbnailUrl();
?>
<div class="category">
<a href="<?php echo $url; ?>">
<img src="<?php echo $img; ?>" title="<?php echo $name; ?>"/>
<div class="text"><h2><?php $name; ?></h2></div>
</a>
</div>
<?php endforeach; ?>
</div>