简体   繁体   English

扩展此代码以打开magento子类别(垂直导航)

[英]Extending this code to open magento subcategories (vertical navigation)

Hey guys, I'm wondering if anyone can help me extend this bit of code- 大家好,我想知道是否有人可以帮助我扩展这段代码,

<h3>Browse by Category:</h3>

<ul>
<?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><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a><ul>";
        foreach ($obj->getCurrentChildCategories() as $subcat) {
            echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>";
        }
        echo "</ul></li>";
    } else {
        echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>";
    }
}
?>
</ul>

Currently, this opens the subcats on a new page upon clicking(which is good). 当前,这会在单击时在新页面上打开子目录(很好)。 I have subcats inside subcats, but those never show up.(on the second page) 我的子目录中有子目录,但这些子目录从未显示。(在第二页上)

So This is as far as I'll get- 所以据我所知

Parent  
-sub  
Parent  
-sub  

But I need : 但是我需要 :

Parent  
-sub  
---sub  
---sub  
---sub  
-sub  
---sub  
---sub  
---sub  

Can anyone help? 有人可以帮忙吗? :) :)

Have you ever visit Fishpig website? 您是否曾经浏览过Fishpig网站? There is an article related with that topic, maybe you you can try their solution. 有一篇与该主题相关的文章,也许您可​​以尝试他们的解决方案。

Listing Categories in Magento 列出Magento中的类别

Old Question- I have rebuilt the navigation since then. 老问题-从那时起我就重新构建了导航。 If anyone needs help feel free to ask. 如果有人需要帮助,请随时询问。

EDIT - 编辑-

I found Rico's "Vertical Navigation with CSS Classes" to suit our needs best, with a little modification of the css. 我发现Rico的“带有CSS类的垂直导航”最适合我们的需求,对CSS进行了一些修改。 It worked right out of the box, and updates depending on the order of our backend categories. 它开箱即用,并根据后端类别的顺序进行更新。 He did a great job in allowing the depth of the sub-categories to be opened via the control panel. 他在允许通过控制面板打开子类别的深度方面做得很出色。

The URL can be found here. 网址可以在这里找到。 It's free, and is supported up to 1.5 : 它是免费的,并且最多支持1.5:

http://www.magentocommerce.com/magento-connect/vertical-navigation-with-css-classes.html http://www.magentocommerce.com/magento-connect/vertical-navigation-with-css-classes.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM