Magento如果subItems处于活动状态,则将子类添加到subitem parent

时间:2018-01-11 09:42:51

标签: php magento

我想在subItems菜单处于活动状态时将活动类添加到li标签。我的代码如下:

<?php foreach ($items as $key => $item) : ?>
<?php
$subItems = $block->getMenuItems($key);
$class = '';
if (count($subItems) > 0) {
    $class .= 'dropdown ';
}
if ($block->isActive($item)) {
    $class .= 'active ';
}
?>
<li class="c-sidebar__item <?php /* @escapeNotVerified */ echo $class; ?>">
    <?php if (count($subItems) > 0) : ?>
        <a class="c-sidebar__link" href="#">
            <div class="c-sidebar__item-content">
                <i class="c-sidebar__item-icon c-sidebar__item-icon--main glyphicon  glyphicon-dashboard"></i>
                <p class="c-sidebar__item-name"><?php echo __($item['label']); ?></p>
                <i class="c-sidebar__item-icon c-sidebar__item-icon--carot glyphicon  glyphicon-menu-down"></i>
            </div>
        </a>

0 个答案:

没有答案