2014-02-18 22 views
0

在最低的类别级别,我的边栏在Magento中消失。 Anchor对于我的所有类别都设置为“否”。最终,我想在侧栏上显示所有主要类别(显然是在每个产品页面上)以及主类别中的子类别。左边栏类别导航在Magento的最后一级类别页面上消失

不知道是什么问题。几乎所有的基础magento代码都有一些风格变化。任何帮助深表感谢!

<?php if (!Mage::registry('current_category')) return ?> 
<?php $_categories = $this->getCurrentChildCategories() ?> 
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?> 
<?php if($_count): ?> 
    <aside id="sidebar"> 
     <div class="sidebar-nav"> 
      <h2><?php echo $this->__('Products') ?></h2> 
      <ul> 
       <?php foreach ($_categories as $_category): ?> 
        <?php if($_category->getIsActive()): ?> 
        <li> 
         <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>) 
        </li> 
        <?php endif; ?> 
       <?php endforeach ?> 
      </ul> 
     </div> 
     <div class="sidebar-nav"> 
      <h2 class="red">Holiday</h2> 
      <ul> 
       <li><a href="#">Christmas</a></li> 
       <li><a href="#">Halloween</a></li> 
       <li><a href="#">Thanksgiving</a></li> 
       <li><a href="#">Easter</a></li> 
       <li><a href="#">4th of July</a></li> 
       <li><a href="#">Valentine's Day</a></li> 
      </ul> 
     </div> 
     <div class="sidebar-nav"> 
      <h2>About Us</h2> 
      <ul> 
       <li><a href="#">About Mary</a></li> 
       <li><a href="#">Press</a></li> 
       <li><a href="#">Licensing</a></li> 
       <li><a href="#">Shows</a></li> 
       <li><a href="#">Custom Work</a></li> 
       <li><a href="#">Contact Us</a></li> 
       <li><a href="#">Privacy Policy</a></li> 
       <li><a href="#">Terms &amp; Conditions</a></li> 
      </ul> 
     </div> 
<script type="text/javascript">decorateDataList('narrow-by-list2')</script> 
<?php endif; ?> 
    </aside> 

回答

1

他们对你的最低类别的消失,因为你的代码是使用:

<?php $_categories = $this->getCurrentChildCategories() ?> 

如果您当前的类别(类别你当前正在查看)没有子类,块将不会显示任何类别(因为getCurrentChildCategories()返回当前类别的子类别)。

左侧的类别将不同的表现取决于被锚是否被设置为Yes或No.

  1. 类别设置为Is Anchor: Yes
    -The留下类别将作为一个过滤器的作用,而不是直接导航链接。当您点击左侧的类别时,您将保持与您正在查看的类别相同,但是页面上的结果将被过滤到所选类别。

  2. 类别设置为Is Anchor: No
    - 左侧类别将用作菜单。当选择一个类别时,用户将被带到该实际类别页面。如果他们导航到的类别页面没有子类别,则左侧不会显示类别。所以你的情况

,你可以设置你的上级类别Is Anchor: Yes和代替过滤菜单链接的最低类别的动作。

如果您希望人们导航到最低级别的子类别,则必须修改模板用于从父类别中拉取类别的功能。有几篇关于StackOverflow的文章已经详细说明了如何做到这一点。

+0

在哪里可以找到这个文件?在哪里改变这个? @Axel – Learner