Answer the question
In order to leave comments, you need to log in
How to set up a search by the description of the property of an element of the file type?
Hello!
Please tell me how to resolve the issue.
There is a site created on the Business editorial office with the decision of the State Site. organizations. The structure of the site is roughly very confusing, it was done once by someone in haste.
The content is a bunch of identical infoblocks (with the same properties and field settings). There are sections, in sections there are elements.
In an element, a set of add. properties of which only properties of the File (multiple) type are used, this property has a value description field included.
Those. each element is an assembly of different files with a description, for example -
инфоблок Экономика >
раздел Торговля>
элемент Нормативно-правовая база>
к элементу приложены файлы: post#1.doc (Описание - Постановление №1)
post#2.doc (Описание - Постановление №2) и т.д
Answer the question
In order to leave comments, you need to log in
BeforeIndex
in /bitrix/php_interface/init.php:
AddEventHandler("search", "BeforeIndex", Array("BeforeIndex", "BeforeIndexHandler"));
CModule::AddAutoloadClasses('', array(
'BeforeIndex' => '/bitrix/php_interface/classes/BeforeIndex.php',
)
);
class BeforeIndex {
function BeforeIndexHandler($arFields) {
$IBLOCK_ID = 1 //нужный инфоблок
if ($arFields["MODULE_ID"] == "iblock" && $arFields["PARAM2"] == $IBLOCK_ID) {
$arSelect = Array("ID", "NAME", "PROPERTY_FILE");
$arFilter = Array("IBLOCK_ID" => $IBLOCK_ID, "ID" => $arFields['ITEM_ID']);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
if ($ar_res = $res->GetNext()) {
//Тут узнаете есть ли файлы или нет и тянете их DESCRIPTION
...
$arFields["BODY"].= PHP_EOL.$DESCRIPTION;
}
}
return $arFields;
}
}
To provide such functionality, you should initially use a standard media library (well, or separately store attached files in a separate infoblock, which is basically the same thing). In my opinion, the most optimal solution is to develop a structure in which a separate infoblock with attachments is displayed. Transfer all elements to it using the API, and then, through the API, correct the property from the file binding to the binding to the infoblock elements. Thus, it remains only to change the output in the templates, a list of all templates can be obtained through, for example, grep in the site folder with the code and id of the previous property. Works approximately 1-1.5 working days. For that, wrap everything you need in your functionality.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question