Views: 8442
Last Modified: 10.10.2012
The following command connects a component to a page:
$APPLICATION->IncludeComponent($componentName, $componentTemplate,
$arParams = array(), $component = null)
here:
$componentName – the full name of a component to be added;
$componentTemplate – the component template;
$arParams – an array of the component input parameters;
$component – a component instance. Used if a component is connected from a composite component template which defines the $component variable.
Consider the following examples of using the components.
1. Connect the bitrix:catalog component with the default template:
$APPLICATION->IncludeComponent("bitrix:catalog","",
array(
"SEF_MODE" => "Y",
"SEF_FOLDER" => "/catalog/",
"IBLOCK_TYPE_ID" => "catalog",
)
);
2. Connect the bitrix:catalog.list component of a composite component template applying the table/index.php template:
$APPLICATION->IncludeComponent("bitrix:catalog.list","table/index.php",
array(
"IBLOCK_TYPE_ID" => "catalog",
),
$component
);
The following predefined variables are available inside a component:
$componentName – the component full name;
$componentTemplate – a template to be applied to a component;
$arParams – the component input parameters (i.e. parameters passed to a component). The parameters are also available by their names;
$componentPath – the path to a component relative to the site root;
$parentComponentName – the parent component name (empty if a component is orphan);
$parentComponentPath – the path to a parent component relative to the site root (empty if a component is orphan).
Besides, a component can access the $APPLICATION, $USER, $DB global variables.