Return to Snippet

Revision: 45230
at April 27, 2011 19:16 by nico65


Initial Code
<?php 
$category = Mage::getModel('catalog/category'); 
$tree = $category->getTreeModel(); 
$tree->load(); 
$ids = $tree->getCollection()->getAllIds(); 
foreach($ids as $id) 
{ 
if($id != 1) 
{ 
$cat = Mage::getModel("catalog/category")->load($id); 
$parentcatname = strtolower(preg_replace('/ /','-',$cat->getName())); 
$subcats = $cat->getChildren(); 
if ($subcats) { 
?> 
<a href="<?php echo $this->getUrl() ?>">Home</a> | 
<?php 
foreach(explode(',',$subcats) as $subCatId) 
{ 
$_category = Mage::getModel('catalog/category')->load($subCatId); 
if($_category->getIsActive()) 
{ 
$caturl = $_category->getURL(); 
$catname = $_category->getName(); 
echo '<a href="'.$caturl.'" title="'.$catname.'">'.$catname.'</a> |'."\n"; 
} 
} 
?> 
<?php 
} 
} 
} 
?>

Initial URL
http://www.magentocommerce.com/boards/viewthread/19476/P15/#t273207

Initial Description

                                

Initial Title
Magento echo all category links

Initial Tags
category, navigation, links, magento

Initial Language
PHP