M
M
Maxim Volkov2020-06-22 11:09:48
1C-Bitrix
Maxim Volkov, 2020-06-22 11:09:48

How to set and get custom parameters of the Bitrix component settings in the $arParams array?

Task: to display the slider, the news list component is used: news.list , with the ability to set parameters: animation effects, slide transition speed, and others. These settings are set in the component settings form, and via $arParams they are obtained in the component template.
In the component template, to set and receive the necessary parameters, the .parameters.php file is created , which contains the following code:

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
 $arTemplateParameters = array(
     'SLIDER_EFFECT' =>  array(
         'NAME'      =>  'Эффект смены слайдов',
         'TYPE'      =>  'LIST',
         'SORT'      =>  '10',
         'VALUES'    =>  array(
             'sliding'   =>  'Скольжение',
             'fading'    =>  'Затухание',
         ),
         'MULTIPLE'  =>  'N',
     ),
     'SLIDER_TIME'   =>  array(
         'NAME'      =>  'Скорость смены слайдов (мс)',
         'TYPE'      =>  'STRING',
         'SORT'      =>  '20',
         'DEFAULT'   =>  '5000',
     ),
 );

As a result, the necessary fields appeared in the component settings:

5ef067054cf31338953693.jpeg

However, the data is not included in the array with the $arParams settings. There are no set parameters in the $arParams['SLIDER_EFFECT'] and $arParams['SLIDER_TIME'] arrays .

Where is the mistake? How to set and pass parameters to component template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smilingcheater, 2020-06-22
@voland700

I'll move my comments to an answer.
Are you sure you saved the file with the connection of this component after changing its settings?
If you look at the file where you connect the component, as PHP code, do these parameters are set in it?
You have only described these parameters so far. Until you save the component with attached parameters, they won't get into $arParams. Only what is written in the php code gets into $arParams.
It will be enough to go into the component connection settings (the window that you have in the question on the 2nd screen) and save it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question