Hi I get an error in the following lines, but I have the following code on two different servers and on one server I don´t get this warning/error:
<?php
// gets the root cat without setting it plain
$root = Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($root);
// create an array for the category navigation
function get_categories($categories) {
$array= '<ul>';
foreach($categories as $category) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$imageFile = Mage::getModel('catalog/category')->load($category->getId())->getThumbnail();
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "catalog/category/" . $imageFile;
// check if a file exists
if(isset($imageFile)) {
$image = '<div class="b_imageWrap"><img src="'. $imageUrl .'" /></div>';
}
$array .= '<li class="b_catId'.$cat->getId().'">'.'<a href="' . Mage::getUrl($cat->getUrlPath()). '">' . $image . $category->getName() . '<div class="b_arrowFlyout"></div>' . '</a>';
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$array .= '<div class="b_flyout"><h1>'.$category->getName().'</h1><h3 class="b_line"><span>UNSERE PRODUKTE</span></h3>';
$array .= '<ul>';
foreach($children as $category) {
$array .= '<li class="b_catId'.$category->getId().'">'.'<a href="' . Mage::helper('catalog/category')->getCategoryUrl($category) . '"><b>' . $category->getName() . '</b></a>';
$array .= '</li>';
}
$array .= '</ul><a class="btn btn-default btn-full" href="' . Mage::getUrl($cat->getUrlPath()). '">ZUR PRODUKTÜBERSICHT</a></div>';
}
$array .= '</li>';
}
return $array . '</ul>';
}
echo get_categories($categories);
?>
Fatal error: Cannot redeclare get_categories() (previously declared in /var/www/production/htdocs/app/design/frontend/default/default/template/page/html/header.phtml:134) in /var/www/production/htdocs/app/design/frontend/default/default/template/page/html/header.phtml on line 161
Line 134 is: function get_categories($categories) {
Line 161 is: } (before the echo get_categories)
I cannot find the mistake here.
Greetings
Daniel