Сейчас выводится сначала разделы, потом элементы. Как вывести все это по сортировке из админки?
В админке проставлено:
Элемент 1 - #1
Элемент 2 - #2
Раздел 1 - #3
Раздел 2 - #4
А выводит:
Раздел 1 - #1
Раздел 2 - #2
Элемент 1 - #3
Элемент 2 - #4
Код:
С битриксом опыта нету, помогите пож-ста..
В админке проставлено:
Элемент 1 - #1
Элемент 2 - #2
Раздел 1 - #3
Раздел 2 - #4
А выводит:
Раздел 1 - #1
Раздел 2 - #2
Элемент 1 - #3
Элемент 2 - #4
Код:
Код |
---|
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?> <? if(!CModule::IncludeModule("iblock")) return; function printElementsRep($sectionId, $printsection, $iblockId, $iblockType, $parent){ if($sectionId == $_GET["parent"] || $sectionId == $_GET["section"] ){ $display = ""; }else{ $display = "display:none;"; } echo '<ul class="dochernya" id="d'.$sectionId.'" style="'.$display.'">'; if($printsection){ printSectionsRep($sectionId, $iblockId, $iblockType); } $arSelect = Array("ID", "NAME", "DATE_ACTIVE_FROM", "PROPERTY_P_MENU_TITLE", "CODE"); $arFilter = Array("IBLOCK_ID"=>$iblockId, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "SECTION_ID" => $sectionId); $res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, Array("nPageSize"=>50), $arSelect); while($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); if($_GET["ID"] != $arFields["ID"]){ $elementCode = $arFields["CODE"] != "" ? $arFields["CODE"] : $arFields["ID"]; $linkUrlWithCode = getSectionsStringMenu($sectionId, $iblockId); if($linkUrlWithCode[strlen($linkUrlWithCode)-1] == "/"){ $linkUrlWithCode = $linkUrlWithCode.$elementCode."/"; }else{ $linkUrlWithCode = $linkUrlWithCode."/".$elementCode."/"; } ?><li class="page_name"><a href="<?=$linkUrlWithCode?>"> <?=$arFields["PROPERTY_P_MENU_TITLE_VALUE"] == "" ? $arFields["NAME"] : $arFields["PROPERTY_P_MENU_TITLE_VALUE"]?></a></li><? }else{ ?><li class="page_name_active"> <?=$arFields["PROPERTY_P_MENU_TITLE_VALUE"] == "" ? $arFields["NAME"] : $arFields["PROPERTY_P_MENU_TITLE_VALUE"]?></li><? } } echo "</ul>"; } function printSectionsRep($sectionId, $iblockId, $iblockType){ $arFilter = Array('IBLOCK_ID'=>$iblockId, 'GLOBAL_ACTIVE'=>'Y', 'IBLOCK_SECTION_ID' => $sectionId); $db_list = CIBlockSection::GetList(Array("SORT"=>"ASC"), $arFilter, true); while($ar_result = $db_list->GetNext()) { if($ar_result["IBLOCK_SECTION_ID"] == $sectionId){ $count = $ar_result["ELEMENT_CNT"]; if($count > 0){ $link_script = "onclick='foo(\"d".$ar_result["ID"]."\")'"; }else{ $link_script = ''; } $elementCode = $ar_result["CODE"] != "" ? $ar_result["CODE"] : $ar_result["ID"]; //echo $elementCode; $linkUrlWithCode = getSectionsStringMenu($sectionId, $iblockId)."/".$elementCode."/"; //echo $linkUrlWithCode; $link = '<div class="this_parent"><a href="'.$linkUrlWithCode.'" style="cursor:pointer;text-decoration:underline;">'.$ar_result["NAME"].'</a></div>'; ?><li class="razdel_name"> <div id="pardd<?=$ar_result["ID"]?>" <?if($ar_result["ID"] != $_GET["section"]){?> <?}?>> <?=$link?> <? //if($count > 0){ printElementsRep($ar_result["ID"], false,$iblockId, $iblockType, $sectionId); //} ?></div> </li> <? /* echo '<li><a href="detailsection.php?section='.$ar_result["ID"].'" style="cursor:pointer; text-decoration:underline;">'.$ar_result["NAME"].'</a>'; if($count > 0){ printElementsRep($ar_result["ID"], false,$iblockId, $iblockType, $sectionId); } echo "</li>"; * */ } } } ?> <ul> <? //print_r($_REQUEST); //print_r($arResult["SECTIONS"]); $CURRENT_DEPTH=$arResult["SECTION"]["DEPTH_LEVEL"]+1; foreach($arResult["SECTIONS"] as $arSection): //echo "current =".$CURRENT_DEPTH ." -- det". $arSection["DEPTH_LEVEL"]; if($CURRENT_DEPTH<$arSection["DEPTH_LEVEL"]){ if($arSection["ID"] == $_GET["parent"] || $arSection["ID"] == $_GET["section"]){ $display = "display:none;"; }else{ $display = "display:none;"; } echo "<ul id= 'd".$arSection["ID"]."' style='list-style-position: inside; padding-left:10px;".$display."'>"; } elseif($CURRENT_DEPTH>$arSection["DEPTH_LEVEL"]){ echo str_repeat("</ul>", $CURRENT_DEPTH - $arSection["DEPTH_LEVEL"]); } $CURRENT_DEPTH = $arSection["DEPTH_LEVEL"]; $count = $arSection["ELEMENT_CNT"]; if($count > 0){ $link_script = "";//"onclick='foo(\"d".$arSection["ID"]."\")'"; }else{ $link_script = ''; } $cat_name = $arSection["UF_MENU_TITLE"] == "" ? $arSection["NAME"] : $arSection["UF_MENU_TITLE"] ; $linkUrlWithCode = getSectionsStringMenu($arSection["ID"], $arSection["IBLOCK_ID"])."/"; $link = '<div class="category_name"><img class="cat-selector-image" src="/razdeli.gif"><a '.$link_script.' href="'.$linkUrlWithCode.'" style="cursor:pointer;">'.$cat_name.'</a></div>'; ?> <li> <div id="pardd<?=$arSection["ID"]?>" <?if($arSection["ID"] != $_GET["section"]){?> <?}?>> <?=$link?> <? //if($count > 0){ printElementsRep($arSection["ID"] , true, $arSection["IBLOCK_ID"], $arSection["IBLOCK_TYPE_ID"], ""); // } ?></div> </li> <?if($arSection["ID"] != $_GET["section"] && $arSection["ID"] != $_GET["parent"] && $arSection["DEPTH_LEVEL"] == 1){?> <script type="text/javascript"> $(document).ready(function() { /* $("#pardd<?=$arSection["ID"]?>").live('mouseenter mouseleave', function() { $("#d<?=$arSection["ID"]?>").stop().toggle("slow"); }); */ $("#pardd<?=$arSection["ID"]?>").mouseover(function() { $("#d<?=$arSection["ID"]?>").stop().show(); }); $("#pardd<?=$arSection["ID"]?>").mouseleave(function() { $("#d<?=$arSection["ID"]?>").stop().hide(); }); $("#d<?=$arSection["ID"]?>").mouseleave(function() { $(this).stop().hide(); }); }); </script> <?}?> <? $all_count++; endforeach?> </ul> |