Answer the question
In order to leave comments, you need to log in
How to hide subsections beyond 3 nestings on Bitrix?
Hello, please tell me how to hide subsections beyond 3 levels of nesting so that they are not displayed in the drop-down menu. Whatever I tried, I rummaged through all the settings.
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<?global $useSeacrh?>
<div class="hidden-xs hidden-sm">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left horizontal-menu" itemscope itemtype="http://www.schema.org/SiteNavigationElement">
<?
$previousLevel = 0;
foreach($arResult as $arItem):?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
<?endif?>
<?if ($arItem["IS_PARENT"]):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li class="<? if ($arItem["SELECTED"]): ?>active<? else: ?>dropdown<? endif ?>"><a itemprop="url" href="<?=$arItem["LINK"]?>" class="dropdown-toggle" data-hover="dropdown"><?=$arItem["TEXT"]?> <i class="fa fa-angle-down"></i></a>
<ul class="dropdown-menu">
<?else:?>
<li class="dropdown-submenu"><a itemprop="url" href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a>
<ul class="dropdown-menu">
<?endif?>
<?else:?>
<?if ($arItem["PERMISSION"] > "D"):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li class="<? if ($arItem["SELECTED"]): ?>active<? else: ?>dropdown<? endif ?>"><a itemprop="url" href="<?=$arItem["LINK"]?>" class="dropdown-toggle" data-close-others="true"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<li class="<? if ($arItem["SELECTED"]): ?>active<? else: ?>dropdown<? endif ?>"><a itemprop="url" href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li>
<?endif?>
<?else:?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a itemprop="url" href="" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<li><a itemprop="url" href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?endif?>
<?endif?>
<?endif?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?endforeach?>
<?//top search?>
<?if($useSeacrh === 'Y'):?>
<li class="dropdown dropdown-aux animate-click" data-animate-in="animated bounceInUp" data-animate-out="animated fadeOutDown" style="z-index:500;">
<a itemprop="url" href="#" class="dropdown-form-toggle" data-toggle="dropdown"><i class="fa fa-search"></i></a>
<ul class="dropdown-menu dropdown-menu-user animate-wr">
<li id="dropdownForm">
<div class="dropdown-form">
<form class="form-horizontal form-light p-10" role="form" method="get" action="<?=SITE_DIR?>search/">
<div class="input-group">
<input type="text" class="form-control" placeholder="<?=GetMessage("MENU_SEARCH_PLACEHOLDER")?>" name="q">
<span class="input-group-btn">
<button class="btn btn-two" type="submit" name="s"><?=GetMessage("MENU_SEARCH_BUTTON")?></button>
</span>
</div>
</form>
</div>
</li>
</ul>
</li>
<?endif;?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
<?endif?>
</ul>
</div>
</div>
<div class="hidden-lg hidden-md">
<ul class="navbar-right mobile_menu">
<?
$previousLevel = 0;
foreach($arResult as $arItem):?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
<?endif?>
<?if ($arItem["IS_PARENT"]):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li class="<? if ($arItem["SELECTED"]):?>selected<?endif?>">
<a itemprop="url" href="<?=$arItem["LINK"]?>">
<?=$arItem["TEXT"]?>
</a>
<ul class="submenu">
<?else:?>
<li class="<? if ($arItem["SELECTED"]):?>selected<?endif?>">
<a itemprop="url" href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a>
<ul class="submenu">
<?endif?>
<?else:?>
<?if ($arItem["PERMISSION"] > "D"):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li class="<? if ($arItem["SELECTED"]):?>selected<?endif?>">
<a itemprop="url" href="<?=$arItem["LINK"]?>">
<?=$arItem["TEXT"]?>
</a>
</li>
<?else:?>
<li class="<? if ($arItem["SELECTED"]):?>selected<?endif?>">
<a itemprop="url" href="<?=$arItem["LINK"]?>">
<?=$arItem["TEXT"]?>
</a>
</li>
<?endif?>
<?else:?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li>
<a itemprop="url" href="" class="<? if ($arItem["SELECTED"]):?>selected<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>">
<?=$arItem["TEXT"]?>
</a>
</li>
<?else:?>
<li>
<a itemprop="url" href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>">
<?=$arItem["TEXT"]?>
</a>
</li>
<?endif?>
<?endif?>
<?endif?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?endforeach?>
<?//top search?>
<?if($useSeacrh === 'Y'):?>
<li class="dropdown dropdown-aux animate-click" data-animate-in="animated bounceInUp" data-animate-out="animated fadeOutDown" style="z-index:500;">
<a itemprop="url" href="<?=SITE_DIR?>search/" class="dropdown-form-toggle"><i class="fa fa-search"></i></a>
</li>
<?endif;?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
<?endif?>
</ul>
</div>
<div class="menu-clear-left"></div>
<?endif?>
Answer the question
In order to leave comments, you need to log in
As far as I understand, the bitrix:menu.sections component generates items for the site menu in one of the .<menu_type_name>.menu_ext.php files.
This component has a DEPTH_LEVEL parameter. Use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question