Trigub_Ilia

Битрикс 24 - Достаем все подразделения в select

Oct 28th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. $rs_Section = CIBlockSection::GetList(array('left_margin' => 'asc'), array('IBLOCK_ID' => 5));
  2. while ( $ar_Section = $rs_Section->Fetch() )
  3. {
  4.     $ar_Result[] = array(
  5.         'ID' => $ar_Section['ID'],
  6.         'NAME' => $ar_Section['NAME'],
  7.         'IBLOCK_SECTION_ID' => $ar_Section['IBLOCK_SECTION_ID'],
  8.         'IBLOCK_SECTION_ID' => $ar_Section['IBLOCK_SECTION_ID'],
  9.         'LEFT_MARGIN' => $ar_Section['LEFT_MARGIN'],
  10.         'RIGHT_MARGIN' => $ar_Section['RIGHT_MARGIN'],
  11.         'DEPTH_LEVEL' => $ar_Section['DEPTH_LEVEL'],
  12.     );
  13. }
  14.  
  15. ?>
  16. <select>
  17.     <option> - Выбрать - </option>
  18.     <?
  19.     foreach( $ar_Result as $ar_Value )
  20.     {
  21.         $s = '';
  22.         for($i = 1; $i <= $ar_Value['DEPTH_LEVEL']; $i++ )
  23.             $s .= '.';
  24.        
  25.         $s .= ' '.$ar_Value['NAME'];
  26.        
  27.         ?><option value="<?=$ar_Value['ID']?>"><?=$s?></option><?
  28.     }
  29.     ?>
  30. </select>
Add Comment
Please, Sign In to add comment