A
A
Askfortrue2019-11-05 20:28:21
1C-Bitrix
Askfortrue, 2019-11-05 20:28:21

How to get the ID of the current directory partition?

Hello! tell me -
How to get the ID of the current directory partition?
The CNC is built on a symbolic code, and on the page itself, the section ID of the current section is needed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Alexandrov, 2019-11-06
@Askfortrue

Getting section data in the section.php file of the catalog complex component by the section symbol code

<?
$rsSections = CIBlockSection::GetList(array(),array('IBLOCK_ID' => $arParams ['IBLOCK_ID'], '=CODE' => $arResult['VARIABLES']['SECTION_CODE']));
if ($arSection = $rsSections->Fetch())
{
echo $arSection['ID'];
}?>

G
Georgy Baruchyan, 2019-11-05
@Snatch87

First, try dumping the $arParams and $arResult variables.
If you don't find them, you can use the old API:
CIBlockSection::GetList as a filter to pass your infoblock id and section code
, or use d7 and orm:

$section = \Bitrix\Iblock\SectionTable::query()
            ->where('IBLOCK_ID', $iblockId)
            ->where('CODE', 'КОД РАЗДЕЛА')
            ->where('ACTIVE', 'Y')
            ->setSelect(['*'])
            ->exec()
            ->fetch()
        ;

In setSelect, instead of ['*'], you can pass the set of fields you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question