M
M
Mikhail Abroskin2016-05-20 14:49:44
1C-Bitrix
Mikhail Abroskin, 2016-05-20 14:49:44

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) и т.д

Accordingly, only the list of attached files is displayed on the element page.
The problem is that for some reason the search does not search either by the names or by the descriptions of these attached files, i.e. if you enter in the search - Decree No. 1, Decree No. 2 or simply Decree, then the search result will be 0.
In the Infoblock property settings, in all infoblocks, the Property values ​​included in the search item is checked. Reindexing, already did all possible options. Nothing helps.
Somehow it is not realistic to remake the entire structure of the files now, a lot of documents have already been entered on the site.
Tell me what to do to make the search work?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
no_one_safe, 2016-05-20
@miker059

BeforeIndex
in /bitrix/php_interface/init.php:

AddEventHandler("search", "BeforeIndex", Array("BeforeIndex", "BeforeIndexHandler"));
CModule::AddAutoloadClasses('', array(
    'BeforeIndex' => '/bitrix/php_interface/classes/BeforeIndex.php',
        )
);

in /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;
    }

}

D
Denis Gorokhov, 2016-05-20
@gorokhov_dv

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.

V
vista1x, 2015-08-03
@Zewkin

Tyts

A
Alexander, 2015-08-03
@zkelo

([\d]{1,2}\s[a-z]+)
The first match is the first day and month.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question