【问题标题】:How to create custom navigation using Magento category links - Magento 1.9如何使用 Magento 类别链接创建自定义导航 - Magento 1.9
【发布时间】:2015-02-03 15:12:34
【问题描述】:

我是 Magento 新手,目前正在使用 Magento 1.9。

问题:- 我有两种类型的菜单,一种是主菜单,另一种是我网站上的移动菜单。我已经自定义了 topMenu html 来满足主菜单的要求,但是我无法找到一种方法来获取类别链接并在不同的内容块中创建移动菜单。

【问题讨论】:

  • 我用来自定义主菜单的文件如下:/public_html/app/design/frontend/rwd/st/template/page/html/topmenu/renderer.phtml

标签: php magento navigation magento-1.9


【解决方案1】:

我已经解决了这个问题。在我的研发过程中,我确实找到了以下问题的多种解决方案。

  1. 基本且最简单的解决方案是https://www.youtube.com/watch?v=gt1ZF8mQxk4

  2. 您也可以通过创建内容块并包含以下代码来实现相同的目的:

    <?php
    $_category  = $this->getCurrentCategory(); 
    $collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
    $helper = Mage::helper('catalog/category');
    ?>
    
    <ul>
    <?php foreach ($collection as $cat):?>
        <?php if($_category->getIsActive()):?>
            <?php 
                 $cur_category = Mage::getModel('catalog/category')->load($cat->getId());
                 $_img = $cur_category->getImageUrl();  
            ?>
            <li>
                <a href="<?php echo $helper->getCategoryUrl($cat);?>">
                     <img src="<?php echo $_img?>" title="$cat->getName()"/>
                     <cite><?php echo $cat->getName();?></cite>
                </a>
            </li>
        <?php endif?>
    <?php endforeach;?>
    </ul>
    

谢谢,编码愉快!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    相关资源
    最近更新 更多