F
F
FlexStat2021-09-14 20:08:20
1C-Bitrix
FlexStat, 2021-09-14 20:08:20

How to display infoblock property in bitrix:catalog.section.list template?

Something I shoveled everything, I just can not figure out how to implement it.
Created a new property (file type) for the elements in the infoblock:

6140d562dc300225497090.png

I go to the element, I see that the property is active, I upload the file:

6140d58318f91629018804.png

Then I include it in the Component Parameters:

6140d59cebcb4293802206.png

after that I go to the template, check the arResult variable and see that the property did not start there :

Array
(
    [SECTIONS] => Array
        (
            [0] => Array
                (
                    [ID] => 1
                    [~ID] => 1
                    [NAME] => Товарные знаки
                    [~NAME] => Товарные знаки
                    [DESCRIPTION] => Представлены основные товарные знаки, которыми владеет компания 
                    [~DESCRIPTION] => Представлены основные товарные знаки, которыми владеет компания 
                    [LEFT_MARGIN] => 1
                    [~LEFT_MARGIN] => 1
                    [RIGHT_MARGIN] => 2
                    [~RIGHT_MARGIN] => 2
                    [DEPTH_LEVEL] => 1
                    [~DEPTH_LEVEL] => 1
                    [IBLOCK_ID] => 2
                    [~IBLOCK_ID] => 2
                    [IBLOCK_SECTION_ID] => 
                    [~IBLOCK_SECTION_ID] => 
                    [LIST_PAGE_URL] => /documents/index.php?ID=2
                    [~LIST_PAGE_URL] => /documents/index.php?ID=2
                    [SECTION_PAGE_URL] => /documents/list.php?SECTION_ID=1
                    [~SECTION_PAGE_URL] => /documents/list.php?SECTION_ID=1
                    [DESCRIPTION_TYPE] => html
                    [~DESCRIPTION_TYPE] => html
                    [CODE] => trade-marks
                    [~CODE] => trade-marks
                    [EXTERNAL_ID] => 81
                    [~EXTERNAL_ID] => 81
                    [IBLOCK_TYPE_ID] => redcode_mcorporate
                    [~IBLOCK_TYPE_ID] => redcode_mcorporate
                    [IBLOCK_CODE] => documents_s1
                    [~IBLOCK_CODE] => documents_s1
                    [IBLOCK_EXTERNAL_ID] => redcode_mcorporate_5
                    [~IBLOCK_EXTERNAL_ID] => redcode_mcorporate_5
                    [GLOBAL_ACTIVE] => Y
                    [~GLOBAL_ACTIVE] => Y
                    [RELATIVE_DEPTH_LEVEL] => 1
                    [EDIT_LINK] => /bitrix/admin/iblock_section_edit.php?IBLOCK_ID=2&type=redcode_mcorporate&ID=1&lang=ru&force_catalog=&filter_section=1&bxpublic=Y&from_module=iblock&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                    [DELETE_LINK] => /bitrix/admin/iblock_section_admin.php?IBLOCK_ID=2&type=redcode_mcorporate&lang=ru&action=delete&ID[]=1&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                    [~ELEMENT_CNT] => 
                    [ELEMENT_CNT] => 
                    [IPROPERTY_VALUES] => Array
                        (
                        )

                    [ELEMENTS] => Array
                        (
                            [0] => Array
                                (
                                    [IBLOCK_ID] => 2
                                    [ID] => 8
                                    [NAME] => Свидетельство на товарный знак 
                                    [PREVIEW_TEXT] => 
                                    [PREVIEW_PICTURE] => /upload/iblock/919/9193a2c53b822f27a18b126018468b74.jpg
                                    [SORT] => 100
                                    [PREVIEW_TEXT_TYPE] => text
                                    [EDIT_LINK] => /bitrix/admin/iblock_element_edit.php?IBLOCK_ID=2&type=redcode_mcorporate&ID=8&lang=ru&force_catalog=&filter_section=1&bxpublic=Y&from_module=iblock&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                                    [DELETE_LINK] => /bitrix/admin/iblock_element_edit.php?IBLOCK_ID=2&type=redcode_mcorporate&lang=ru&force_catalog=&filter_section=1&IBLOCK_SECTION_ID=1&bxpublic=Y&from_module=iblock&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                                )

                            [1] => Array
                                (
                                    [IBLOCK_ID] => 2
                                    [ID] => 9
                                    [NAME] => Свидетельство на товарный знак 
                                    [PREVIEW_TEXT] => Свидетельство на товарный знак 
                                    [PREVIEW_PICTURE] => /upload/iblock/ed7/ed7a6f9e5b3109313e76f658d1420eef.jpg
                                    [SORT] => 200
                                    [PREVIEW_TEXT_TYPE] => text
                                    [EDIT_LINK] => /bitrix/admin/iblock_element_edit.php?IBLOCK_ID=2&type=redcode_mcorporate&ID=9&lang=ru&force_catalog=&filter_section=1&bxpublic=Y&from_module=iblock&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                                    [DELETE_LINK] => /bitrix/admin/iblock_element_edit.php?IBLOCK_ID=2&type=redcode_mcorporate&lang=ru&force_catalog=&filter_section=1&IBLOCK_SECTION_ID=1&bxpublic=Y&from_module=iblock&return_url=%2Fcompany%2Fdocuments%2F%3Fbitrix_include_areas%3DY%26clear_cache%3DY
                                )

                        )

                )


Help me figure out how to add a property to the arResult array, through result_modifier.php
And how to display this thing in a template

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FlexStat, 2021-09-16
@FlexStat

In general, thank you all. As a result, done through the properties of the element.
Added to the template file:

$LINK = (!empty($arElement["DOCUMENTS"]) ? $arElement["DOCUMENTS"] : $arElement["PREVIEW_PICTURE"]);
        $DOWNLOAD_ATTRIBUTE = (!empty($arElement["DOCUMENTS"]) ? 'download="'.$arElement["NAME"].'"' : '');


<a href="<?=$LINK;?>" <?=$DOWNLOAD_ATTRIBUTE;?> class="fancybox" title="<?=$arElement["PREVIEW_TEXT"];?>" rel="document">

in result_modifier:
if(in_array("DOCUMENTS", $arSelect))
      $arItem["DOCUMENTS"] = CFile::GetPath($arItem["PROPERTY_DOCUMENTS_VALUE"]);

S
scottparker, 2021-09-14
@scottparker

you added a property of the infoblock element and want to get it in the section? stupid)

Y
Yariy, 2021-09-15
@Yariy

You use the "list of sections" component, where, accordingly, the sections of the infoblock are displayed.
Accordingly, either the property must be set for the section, or you will have to act in two stages:
In the result_modifier for each output section, get a list of elements (with properties, respectively). In this case, what you're displaying already has elements, but they don't have properties. It is necessary to add all the IDs of the elements into an array and call GetList with a filter by ID and a selection of the desired property
In the template, display elements with properties for each section
But! It seems to me that the component is incorrectly selected here, use bitrix:catalog.section for the root section. There in the parameters specify the desired property

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question