K
K
Ken Jee2020-12-03 16:21:47
1C-Bitrix
Ken Jee, 2020-12-03 16:21:47

How to get a directory partition tree in the form of a nested array in Bitrix?

There is a directory with sections, which, of course, are nested into each other (the stone managed to find out from the docks in Bitrix, this is decided at the level of service properties LEFT_MARGIN, RIGHT_MARGIN and DEPTH_LEVEL).

Is there a functionality that returns a section tree from a specified element (for example, from CIBlockSection::GetByID) as a multidimensional array, where the nesting of elements corresponds to the PARREN -> CHILD scheme?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anubis_I, 2020-12-08
@Machez

select sections using CIBlockSection::GetTreeList, and fill the resulting array (use LEFT_MARGIN+DEPTH_LEVEL)

R
Roman Gritsuk, 2020-12-03
@winer

There is NO standard method in the Bitrix API that would return a section tree from the specified element .
But you can use CIBlockSection::GetNavChain , which returns the tree path from the root to the SECTION_ID section as an array.
If it is important for you to see the output data set in the form of a tree, write a wrapper function over CIBlockSection::GetNavChain, which will convert the bitrix array into the format you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question