There is an information block with contractors where the properties of Name, E-mail, etc. are entered.

It is necessary, having email, to receive the name. Apparently, you need to put it in $ arFilter, but I do not even know how this property is named.

How to do it?

$arSelect = array(); $arFilter = Array( "IBLOCK_ID" => 52, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y" ); $res = CIBlockElement::GetList(Array(), $arFilter, false, "", $arSelect); $conractors = array(); while($ob = $res->GetNextElement()){ $arFields = $ob->GetFields(); $conractors[$arFields['ID']] = $arFields['NAME']; } 

This code displays the name.

  • If the answer to the question was exhaustive, please confirm it as resolved. - Kyper

2 answers 2

If the element is added as an information block property with the name EMAIL, then:

 $arFilter = Array( "IBLOCK_ID" => 52, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "PROPERTY_EMAIL" => "abcd@bla-bla.ru" ); 
  • All the same, it gives all the contractors, and only one is needed, which has such an e-mail. Apparently, the field is not called "PROPERTY_EMAIL". And how to find the name of the field for e-mail? - Sergey
  • In other words, you need to find an element by property value. - Sergey
  • In the admin panel you need to look at the name of the field - Dmitry Kozlov

In the file template.php write the output of the $arResult to the page. Next, look at what field you have stored the property values you need . After you have found the right field, you foreach through the entire array through foreach and see exactly where (in which element of the information block) your field is located. Found the nested array (information block element), contact the address of the field you want to receive and output it

  • Also, in order to find out the code of the desired property, go to Контент>Инфоблоки>Типы инфоблоков>Ваш_тип_инфоблока>Ваш_инфоблок>Свойства . Next, look at the name of the property of its code. - Kyper