Приветствую всех!
Собственно сам код[CODE]<?$oldLevel = 0;?>
<?$arSearch=array();?>
<?if (!empty($arResult["SectionTree"])):?>
<?foreach($arResult["SectionTree"] as $sKey=>$arSection):?>
<?if ($sKey==0) continue;?>
<?$arSearch[$arSection['ID']]=array('found'=>0,'items'=>array());?>
<? if ($arSection['DEPTH_LEVEL']<=$oldLevel):?>
<?=str_repeat('</ul></li>',($oldLevel-$arSection['DEPTH_LEVEL']))?>
<? endif; ?>
<?
if ($arSection['DEPTH_LEVEL'] == 1):
if ($arSection['DEPTH_LEVEL']<=$oldLevel): ?>
<?= '</div></div>' ?>
<? endif; ?>
<div id="sec_<?=$arSection['ID']?>" class="services-list-item">
<div class="services-list-header"><?=$arSection['NAME']?></div>
<div class="services-list-content white-content-box">
<ul>
<?if (!empty($arSection['ITEMS'])): ?>
<?foreach($arSection['ITEMS'] as $arService):?>
<?$arSearch[$arSection['ID']]['items'][$arService['ID']]=array(
'id'=>$arService['ID'],
'sid' => $arSection['ID'],
'name' => strtoupper($arService['NAME']),
);?>
<li id="sec_<?=$arSection['ID']?>_service_<?=$arService['ID']?>">
<a href="<?=$arService['DETAIL_URL']?>">
<?=$arService['NAME']?>
<?if (!empty($arService['PRICES'])):?>
<?$price = current($arService['PRICES'])?>
<?if ($price['VALUE']!=0):?>
<span class="fl-r">
<?if (!empty($price['CURRENCY']) && $price['CURRENCY']!="RUB"):?>
<?=$price['PRINT_VALUE']?>
<?else:?>
<?=$price['VALUE']?> p
<?endif?>
</span>
<?endif;?>
<?endif?>
</a>
</li>
<?endforeach;?>
<? endif; ?>
<? else : ?>
<li><?=$arSection['NAME']?>
<?if (!empty($arSection['ITEMS'])):?>
<ul>
<?foreach($arSection['ITEMS'] as $arService):?>
<?$arSearch[$arSection['ID']]['items'][$arService['ID']]=array(
'id'=>$arService['ID'],
'sid' => $arSection['ID'],
'name' => strtoupper($arService['NAME']),
);?>
<li id="sec_<?=$arSection['ID']?>_service_<?=$arService['ID']?>">
<a href="<?=$arService['DETAIL_URL']?>">
<?=$arService['NAME']?>
<?if (!empty($arService['PRICES'])):?>
<?$price = current($arService['PRICES'])?>
<?if ($price['VALUE']!=0):?>
<span class="fl-r">
<?if (!empty($price['CURRENCY']) && $price['CURRENCY']!="RUB"):?>
<?=$price['PRINT_VALUE']?>
<?else:?>
<?=$price['VALUE']?> p
<?endif?>
</span>
<?endif;?>
<?endif?>
</a>
</li>
<?endforeach;?>
<? if (!isset($arSection['IS_PARENT']) || !$arSection['IS_PARENT']): ?>
</ul>
<? endif; ?>
<?endif;?>
<? if (!isset($arSection['IS_PARENT']) || !$arSection['IS_PARENT']): ?>
</li>
<? endif; ?>
<? endif; ?>
<?$oldLevel = $arSection['DEPTH_LEVEL']?>
<?endforeach;?>
<? if ($oldLevel): ?>
<?if ($oldLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($oldLevel-1) );?>
<?endif?>
</div></div>
<?endif?>
<?endif?>
<?if (!empty($arResult["SectionTree"][0]['ITEMS'])):?>
<div id="sec_<?=$arSection['ID']?>" class="services-list-item">
<div class="services-list-header"><?= GetMessage('MC_OTHER_SERVICES'); ?></div>
<div class="services-list-content white-content-box">
<ul>
<?foreach($arResult["SectionTree"][0]['ITEMS'] as $arService):?>
<?$arSearch[$arSection['ID']]['items'][$arService['ID']]=array(
'id'=>$arService['ID'],
'sid' => $arSection['ID'],
'name' => strtoupper($arService['NAME']),
);?>
<li id="sec_<?=$arSection['ID']?>_service_<?=$arService['ID']?>">
<a href="<?=$arService['DETAIL_URL']?>">
<?=$arService['NAME']?>
<?if (!empty($arService['PRICES'])):?>
<?$price = current($arService['PRICES'])?>
<?if ($price['VALUE']!=0):?>
<span class="fl-r">
<?if (!empty($price['CURRENCY']) && $price['CURRENCY']!="RUB"):?>
<?=$price['PRINT_VALUE']?>
<?else:?>
<?=$price['VALUE']?> p
<?endif?>
</span>
<?endif;?>
<?endif?>
</a>
</li>
<?endforeach;?>
</ul>
</div>
</div>
<?endif;?>
[/CODE]
Вывод результатов производится в в древовидном виде, но с уровнем вложенности 3 и более возникает проблема
[CODE]<!-- корректный вывод в 2 уровня -->
<ul>
<li>1 уровень
<ul>
<li>2 уровень</li>
</ul>
</li>
</ul>
[/CODE][CODE]<!-- если выводим в 3 уровня -->
<ul>
<li>1 уровень</li>
<li>2 уровень</li>
<ul>
<li>3 уровень</li>
</ul>
</ul>
[/CODE]Прошу помощи. Не могу решить задачу корректного вывода списка.
Заранее спасибо!