【发布时间】:2011-03-18 16:53:35
【问题描述】:
我创建了一个自定义模板(mytheme/template/catalog/navigation/left_parent_category.phtml)来显示当前类别的父类别。
<?php
echo '<div class="box base-mini">';
echo '<ol>';
$currentCat = Mage::registry('current_category');
if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
{
// current category is a toplevel category
$loadCategory = $currentCat;
}
else
{
// current category is a sub-(or subsub-, etc...)category of a toplevel category
// load the parent category of the current category
$loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
}
$subCategories = explode(',', $loadCategory->getChildren());
foreach ( $subCategories as $subCategoryId )
{
$cat = Mage::getModel('catalog/category')->load($subCategoryId);
if($cat->getIsActive())
{
echo '<li><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
}
}
echo '</ol>';
echo '</div>';
?>
我在 magento 管理员的子类别中用一些 xml 覆盖布局:
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left_parent_category.phtml"/>
</reference>
php 和 xml 一切正常,但由于某种原因它显示了两次。我不知道为什么这个模板会被调用两次。任何帮助将不胜感激。
PS...这是针对 Magento 1.3 的
【问题讨论】:
标签: php xml zend-framework magento