Views: 9290
Last Modified: 10.09.2014

Each component has a set of variables in which it receives codes or other attributes of requested data from the outside. For example, the component bitrix:catalog.section has variables IBLOCK_ID and SECTION_ID in which it receives and processes codes of the catalog and the product group, accordingly.

All components that form part of a composite component must have a single set of variables. For example, the composite component bitrix:catalog and all simple components (bitrix:catalog.list, bitrix:catalog.section etc.), under its control work with the variables IBLOCK_ID, SECTION_ID, ELEMENT_ID, and others.

If the developer wants to redefine the component variables when placing a composite component on a page, the developer must set up the parameter VARIABLE_ALIASES among the incoming parameters of the component.

When connecting a component in the SEF mode, this parameter must look as follows:

"VARIABLE_ALIASES" => array( 
      "list" => array(),
      "section" => array(
                        "IBLOCK_ID" => "BID",
                        "SECTION_ID" => "ID"
                        ),
                        "element" => array(
                        "SECTION_ID" => "SID",
                        "ELEMENT_ID" => "ID"
                        ),
)

Here, array codes are consistent with the codes in the path template array. For each path, their own redefinitions of variables can be set up.

When connecting a component not in the SEF mode, this parameter must be:

"VARIABLE_ALIASES" => array(
                           "IBLOCK_ID" => "BID",
                           "SECTION_ID" => "GID",
                           "ELEMENT_ID" => "ID",
)

Example No. 1:

Let us assume that the component bitrix:catalog connected in the file /fld/cat.php must work with the paths:
/catalog/index.php – for a list of catalogs,
/catalog/section/group_code.php?ID=catalogue_code – for a group of goods,
/catalog/element/goods_code.php?ID=group_code – for detailed information about an item of goods.

The following parameters must be set up in the incoming parameters for component connection:

"SEF_MODE" => "Y",    
"SEF_FOLDER" => "/catalog/",
"SEF_URL_TEMPLATES" => array(
                    "list" => "index.php",
                    "section" => "section/#SECTION_ID#.php?ID=#IBLOCK_ID#",
                    "element" => "element/#ELEMENT_ID#.php?ID=#SECTION_ID#"    
                            ),
"VARIABLE_ALIASES" => array(
                     "list" => array(),
                     "section" => array(
                                   "IBLOCK_ID" => "ID"),
                     "element" => array(
                                   "SECTION_ID" => "ID",),    

Example No. 2:

Let us assume that the component bitrix:catalog connected in the file /fld/cat.php must work with the paths
/fld/cat.php – for a list of catalogs,
/fld/cat.php?BID=catalogue_code&SID=group_code – for a group of goods,
/fld/cat.php?ID=goods_code&SID=group_code – for detailed information about an item of goods.

The following parameters must be set up in the incoming parameters for a component connection:

"SEF_MODE" => "N",
"VARIABLE_ALIASES" => array(
                           "IBLOCK_ID" => "BID",
                           "SECTION_ID" => "SID",
                           "ELEMENT_ID" => "ID",
                           ),


Courses developed by Bitrix24