monsieurbiz/mbiz_menu

Magento模块,提供更优的菜单块。

安装: 389

依赖项: 1

建议者: 0

安全性: 0

星级: 3

关注者: 8

分支: 2

开放问题: 0

类型:magento-module

0.1.1 2017-01-19 18:27 UTC

This package is auto-updated.

Last update: 2024-08-27 23:12:01 UTC


README

Mbiz_Menu是一个提供优化菜单的简单块的Magento 1模块。

用法

mbiz_menu/page_html_topmenu提供2种方法

  1. getCategoriesTree(),该方法返回主分类及其子分类。子分类可以通过方法$cat->get_children()获取。
  2. getCategories,该方法返回菜单中所有可用的分类。

每个分类有2个新数据可用

  • contains_current_category设置为true,如果分类的子分类中包含当前分类。
  • is_current_category设置为true,如果分类是实际的当前分类。

示例

未提供模板。但这里有一个非常简单的示例

<?php
/* @var $this Mbiz_Menu_Block_Page_Html_Topmenu */
$_tree   = $this->getCategoriesTree();
$_output = $this->helper('catalog/output');
?>
<ul>
<?php foreach ($_tree as $_mainCategory): ?>
    <li class="<?php if ($_mainCategory->getIsCurrentCategory() || $_mainCategory->getContainsCurrentCategory()): ?>active<?php endif; ?>">
        <a href="<?php echo $_mainCategory->getUrl(); ?>">
            <?php echo $_output->categoryAttribute($_mainCategory, $_mainCategory->getName(), 'name'); ?>
        </a>
        <?php if ($_children = $_mainCategory->get_children()): ?>
        <ul>
            <?php foreach ($_children as $_child): ?>
            <li class="<?php if ($_child->getIsCurrentCategory()): ?>current<?php endif; ?>">
                <a href="<?php echo $_child->getUrl(); ?>">
                    <?php echo $_output->categoryAttribute($_child, $_child->getName(), 'name'); ?>
                </a>
            </li>
            <?php endforeach; ?>
        </ul>
        <?php endif; ?>
    </li>
<?php endforeach; ?>
</ul>

默认情况下,块使用72小时的缓存有效期。当然,默认值可以被覆盖。