23 сентября 2016
Нет комментариев
result_modifier.php
$menuList=array(); $lev=0; $lastInd=0; $parents=array(); foreach($arResult as $arItem){ $lev=$arItem['DEPTH_LEVEL']; if($arItem['IS_PARENT']){ $arItem['CHILDREN']=array(); } if($lev==1){ $menuList[]=$arItem; $lastInd=count($menuList)-1; $parents[$lev]=&$menuList[$lastInd]; }else{ $parents[$lev-1]['CHILDREN'][]=$arItem; $lastInd=count($parents[$lev-1]['CHILDREN'])-1; $parents[$lev]=&$parents[$lev-1]['CHILDREN'][$lastInd]; } } $arResult=$menuList;
template.php
if(empty($arResult))return; foreach($arResult as $itemIndex=>$arItem){ if($arItem['SELECTED']){ echo '<ul>'; foreach($arItem['CHILDREN'] as $arChild){ $arChildActive=($arChild['SELECTED'])?' class="active"':''; echo '<li'.$arChildActive.'>'; echo '<a href="'.$arChild['LINK'].'">'.$arChild['TEXT'].'</a>'; echo '</li>'; } echo '</ul>'; } }
.left1.menu.php
$aMenuLinks=Array();
.left1.menu_ext.php
if(!defined("B_PROLOG_INCLUDED")||B_PROLOG_INCLUDED!==true)die(); global $APPLICATION; $aMenuLinksExt=$APPLICATION->IncludeComponent("bitrix:menu.sections","",array( "IS_SEF"=>"Y", "SEF_BASE_URL"=>"", "SECTION_PAGE_URL"=>"/section/#SECTION_CODE#/", "DETAIL_PAGE_URL"=>"/section/#SECTION_CODE#/#ELEMENT_CODE#", "IBLOCK_TYPE"=>"razdel", "IBLOCK_ID"=>"81", "DEPTH_LEVEL"=>"2", "CACHE_TYPE"=>"A", "CACHE_TIME"=>"0", "CACHE_TYPE"=>"A", "CACHE_TIME"=>"3600" ), false ); $aMenuLinks=array_merge($aMenuLinks,$aMenuLinksExt);
Вызов:
$APPLICATION->IncludeComponent("bitrix:menu","vert",array( "ROOT_MENU_TYPE"=>"left1", "MENU_CACHE_TYPE"=>"A", "MENU_CACHE_TIME"=>"3600", "MENU_CACHE_USE_GROUPS"=>"Y", "MENU_CACHE_GET_VARS"=>array( ), "MAX_LEVEL"=>"2", "CHILD_MENU_TYPE"=>"left1", "USE_EXT"=>"Y", "DELAY"=>"N", "ALLOW_MULTI_SELECT"=>"N" ), false );