我将创建一个电子商务网站。我选择了magento 1.7。但我是magento的新手。我在 /app/design/frontend/default/default/layout/catalog.xml 中写了以下代码 我的代码是
<block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left_nav.phtml" />
另一个页面我更改了 left_nav.phtml /app/design/frontend/default/default/template/catalog/navigation/left_nav.phtml 中的代码
<h2>Browse</h2>
<div class="block">
<ul id="nav_category" class="nav_category">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
<?php
$obj = new Mage_Catalog_Block_Navigation();
$store_cats = $obj->getStoreCategories();
$current_cat = $obj->getCurrentCategory();
$current_cat = (is_object($current_cat) ? $current_cat->getName() : '');
foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li class="current"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n";
foreach ($obj->getCurrentChildCategories() as $subcat) {
echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>\n";
}
echo "</ul>\n</li>\n";
} else {
echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n";
}
}
?>
但它不会在左侧栏中显示类别。任何人请帮助我。
<---------------------------------------------------------------------------------------->
它开始显示我把这一行放在catalog.xml中
<block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left_nav.phtml" />
和 left_nav.phtml 中的这一行
<h2>Browse</h2>
<div>
<ul id="nav_category">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
这行得通。谢谢大家的支持。