嗨,我在以下几行中收到错误,但我在两台不同的服务器上有以下代码,在一台服务器上我没有收到此警告/错误:
<?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);
?>
致命错误:无法在 /var/www/production 中重新声明 get_categories()(之前在 /var/www/production/htdocs/app/design/frontend/default/default/template/page/html/header.phtml:134 中声明) /htdocs/app/design/frontend/default/default/template/page/html/header.phtml 在第 161 行
第 134 行是:function get_categories($categories) {
第 161 行是:} (before the echo get_categories)
我在这里找不到错误。
问候
丹尼尔