我想在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>