Hello! There is such a task to make a web interface for sending SMS. Roughly speaking there is a text field and a field for several numbers. By pressing the button using the POST method, a message is sent in the form: номер:текст
, the message ID
returned. How do I store in the info block ID:номер
within one item?
|
1 answer
If you need to store in the information block, then:
- You must create a property "phone number" (PROPERTY_PHONE)
- On the page we write a handler that will add the item.
Handler Code:
<? if(isset($_REQUEST["phone"]) && isset($_REQUEST["mess"]) ){ $el = new CIBlockElement; $PROP = array(); $PROP["PHONE"] = $_REQUEST["phone"]; // свойству с кодом 12 присваиваем значение "Белый" $arLoadProductArray = Array( "MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем "IBLOCK_SECTION_ID" => false, // элемент лежит в корне раздела "IBLOCK_ID" => 18,//указать свой "PROPERTY_VALUES"=> $PROP, "NAME" => "Элемент", "ACTIVE" => "Y", // активен "DETAIL_TEXT" => $_REQUEST["mess"], ); if($PRODUCT_ID = $el->Add($arLoadProductArray)) echo $PRODUCT_ID; else echo "Error: ".$el->LAST_ERROR; }?>
But for your task it is better to use “Highload-blocks”.
- those. It turns out the phone number is in the property, and the ID in the full news? I also need to store several, not one, a pair of
ID:номер
, for this purpose it seems to me that it does not quite fit - S.Ivanov - Well, you can create your own element for each number, or you can make the PHONE property multiple and write down all the options - Mihanik71
|
PROPERTY_PHONE
property, which would put the phone number in the value, and the resulting ID in theXML_ID
. So it is more correct from the point of view of architecture, as it seems to me. - Nikolaj SarryXML_ID
what isXML_ID
where to read more about this? - S.IvanovXML_ID
exists on properties of type "list". In principle, by such an analogy, you can create your own key-value type. - Nikolaj Sarry