G
G
goozer2021-02-02 11:01:47
1C-Bitrix
goozer, 2021-02-02 11:01:47

How to display an element in the presence of a property (Bitrix)?

Hello. There is a property in element properties. If there is a property, you need to display elements with this property in one block. If the property is empty, then the elements without the property are placed in another block.
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vekov, 2021-02-02
@goozer

The question is rather vaguely written.
If we are talking about how to separate elements with a filled property from elements with an empty one, you can do this:

$IblockID = 1;
$res = CIBlockElement::GetList([], ['IBLOCK_ID' => $IblockID], false, false, ['IBLOCK_ID', 'NAME', 'PROPERTY_ISEMPTY']);
while($item = $res -> Fetch())
{
    if($item['PROPERTY_ISEMPTY_VALUE'])
    {
        $arResult['FILLED'][] = $item;
    }
    else
    {
        $arResult['EMPTY'][] = $item;
    }
}

The output will be 2 arrays - FILLED (where the property is filled) and EMPTY (where it is empty).
Instead of ISEMPTY - you need to substitute the code of your property.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question