K
K
KhmBoris2015-08-15 14:14:52
API
KhmBoris, 2015-08-15 14:14:52

How to add a value to a multiple property of the html/text type in a specific property in Bitrix?

Adding a property to an element is easy:

if(CModule::IncludeModule("iblock"))
{
$ELEMENT_ID = "6095"; //ID элемента
$BL_ID = "32";//Ид блока
$PR_VALUE_NOTE['UF_NOTE_USER'][] = array("VALUE" => array ("TEXT" => "Вася привет!", "TYPE" => "text"));//переменная нотеузер, символьный код свойства типа html/text, далее сам текст и тип
CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, $BL_ID, $PR_VALUE_NOTE);//апи добавления
}

Everything is working. But will add erasing all previous entries in the first one. If you need to save them, then they are obtained first by the GetProperty method, a new element is thrown to the end of the array, and then everything is added in a crowd with new values ​​in the above way. Unfortunately, Bitrix does not provide for another.
The question is how to change/add/read the value in a particular property of this multiple property, sorry for the tautology?
The essence of the task is to create notes. There are a number of infoblock elements logically combined, for example, into a Course or a Chapter with articles. Each element must be assigned one writable or retrievable element of this multiple property. something like this:
Chapter on the benefits of smoking (Infobox 1)
Article 1
Article 2
Article 3
User notes (Infoblock2) to the "Chapter on the benefits of smoking"
Multiple property of type html/text
Some text of the user (to article 1) - one entry in the multiple property of type html/text
Some text of the user (to article 2) - second entry in a multiple property of type html/text
Some user text (to article 3) - the third entry in a multiple property of type html/text
So the question is how to get read/write access to a multiple property such as article3. If there are 80 articles..... i.e. there will be 80 such entries in the multiple property... how to get, for example, a note at number 73 to article number 73? Each entry has a PROPERTY_VALUE_ID in the html/text multiple property...but it doesn't appear anywhere...
As an idea, before the user's note, insert the #NOMER_1# marker and then write it together with the note inside. When to extract to read the marker .... but these are such crutches ... creepy ... can't it be simpler, like with an element of the list type, for example? He has an ID there for each multiple property.
Others, help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KhmBoris, 2015-08-15
@KhmBoris

Just in case: You can get data from the field

if(CModule::IncludeModule("iblock"))
{
$ELEMENT_ID = "6095";
$BL_ID = "32";
$VALUES = array();
$res = CIBlockElement::GetProperty($BL_ID, $ELEMENT_ID, Array("sort"=>"asc"), array("CODE" => "UF_NOTE_USER"));
    while ($ob = $res->GetNext())
    {
        $VALUES[] = $ob['VALUE'];
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question