E
E
Evgeniy Evsyukov2021-11-26 21:50:42
PHP
Evgeniy Evsyukov, 2021-11-26 21:50:42

How to display the elements of news.list by the value of its property?

Before calling the news component I do

$GLOBALS['arrFilter'] = ['PROPERTIES' => ['CITY_INFO' = > ['ID' => $_POST['id']]]];// пробовал так же в post[id] напрямую указать id всё равно не работает

and accordingly in the news list itself "FILTER_NAME" => "arrFilter", the problem is that it filters only the id of the element, but not by property.
that is, if output like this, it will display news with ID 1. Are there any alternative solutions for filtering by property? Essence of the question: you need to display the news for which the city is equal to Moscow for example $GLOBALS['arrFilter'] = ['ID' => 1]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-11-26
@venomphp

This CIBlockElement::GetList function is called in the component, according to its filtering rules, and you need to use it, that is, in your situation, the filter should be like this

$GLOBALS['arrFilter'] = ['PROPERTY_CITY_INFO' => $_POST['id']];

if, for example, by the name of the attached element, then like this
$GLOBALS['arrFilter'] = ['=PROPERTY_CITY_INFO.NAME' => 'Москва'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question