Magento显示当前类别级别,父级和祖父级

时间:2017-12-29 09:07:26

标签: php magento navigation themes

我们有一个magento 1.9安装,在左侧我们想要显示3个级别类别,如附图所示(面包屑图像用于显示级别)。目前,我能够获得当前类别及其父母。

下面是我想要它的例子。

你可以帮我解决这个问题吗?

Left navigation

Breadcrumbs

这是我们到目前为止的代码

    <?php 
$level = $this->getCurrentCategory()->getParentCategory()->getLevel();
if($level > 1){                 
        echo '
            <p class="back-to-parent">
                <a href="' . $this->getCurrentCategory()->getParentCategory()->getUrl() . '">
                    <i class="fa fa-arrow-left" aria-hidden="true"></i> ' . $this->getCurrentCategory()->getParentCategory()->getName() . '
            </a></p>';
    }
    else{
        //
    }
?>

<?php if ($categories = $this->getCategoriesNavMenu()): ?>
<div id="sidebar-nav" class="block sidebar-nav-left <?php echo $this->getBlockAlias() ?>">

    <button type="button" class="btn visible-xs btn-block btn-primary" data-toggle="collapse" data-target="#sidebar-nav-content">Meer categorie&euml;n <i class="fa fa-filter" aria-hidden="true"></i></button>
    <div id="sidebar-nav-content" class="collapse">
        <div class="block-content">
            <ul id="sidebar-nav-menu">
            <?php if ($this->showHome()): ?>
                <li class="<?php echo $this->getHomeClasses() ?>">
                    <a href="<?php echo $this->getBaseUrl() ?>"><span class="category_name">Home</span></a>
                </li>
            <?php endif; ?>
            <?php echo $categories; ?>
            </ul>

        </div>
    </div>
    <?php if ($this->getConfig()->isCollapsible()): ?>
    <script type="text/javascript" language="javascript">
    //<![CDATA[

    Codnitive = {
        expandMenu: function(parent) 
        {
            var mode = parent.getElementsByTagName("ul")[0].getAttribute("expanded");
            (mode == 1) ? Codnitive.collapse(parent) : Codnitive.expand(parent);
        },

        expand: function(parent)
        {
            parent.getElementsByTagName("ul")[0].style.display = "block";
            parent.getElementsByTagName("span")[0].style.backgroundPosition = "right center";
            parent.getElementsByTagName("ul")[0].setAttribute("expanded", "1");
        },

        collapse: function(parent)
        {
            parent.getElementsByTagName("ul")[0].style.display = "none";
            parent.getElementsByTagName("span")[0].style.backgroundPosition = "left center";
            parent.getElementsByTagName("ul")[0].setAttribute("expanded", "0");
        }
    };

    //]]>
    </script>
    <?php endif; ?>
</div>
<?php endif ?>

0 个答案:

没有答案