【问题标题】:Left sidebar category navigation disappearing on last level category pages in MagentoMagento 的最后一级类别页面上的左侧边栏类别导航消失
【发布时间】:2014-02-18 23:26:37
【问题描述】:

在最低的类别级别上,我的侧边栏在 Magento 中消失了。对于我的所有类别,Anchor 都设置为 no。最终,我想在侧边栏(显然在每个产品页面上)显示所有主要类别,并在主要类别中显示子类别。

不确定是什么问题。几乎带有一些样式更改的基本 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>

【问题讨论】:

    标签: magento navigation anchor categories sidebar


    【解决方案1】:

    它们正在您的最低类别中消失,因为您的代码正在使用:

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

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

    根据 Is Anchor 设置为 Yes 还是 No,左侧类别的行为会有所不同。

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

    2. 类别设置为Is Anchor: No
      - 左侧类别将用作菜单。选择类别后,用户将被带到该实际类别页面。如果他们导航到的类别页面没有子类别,则左侧不会出现任何类别。

    因此,在您的情况下,您可以将上层类别设置为 Is Anchor: Yes,而最低类别将充当过滤器而不是菜单链接。

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

    【讨论】:

    • 在哪里可以找到这个文件?在哪里改变这个? @Axel
    猜你喜欢
    • 2012-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多