Views: 8211
Last Modified: 19.09.2014

Additional Methods Available in Components and Templates

Additional methods from the class CComponentEngine can be used in components and templates.

string CComponentEngine::MakePathFromTemplate($pageTemplate, $arParams);

where::
$pageTemplate - a template of the type /catalog/#IBLOCK_ID#/section/#SECTION_ID#.php or catalog.php?BID=#IBLOCK_ID#&SID=#SECTION_ID#,
$arParams - an associative array of reparametrization where the parameter name is the key and the parameter value is the value. It returns a path based on the path template $pageTemplate and reparametrization.

Example:

$url = CComponentEngine::MakePathFromTemplate
("/catalog/#IBLOCK_ID#/section/#SECTION_ID#.php", 
        array( 
             "IBLOCK_ID" => 21, 
             "SECTION_ID" => 452  
             ) 
);

Organizing an Explicit Connection among the Components on the One Page of a Composite Component

Explicit connection among the components can be organized through return values and incoming parameters of these components.

If data from the component comp1 must be transferred to the component comp2, in the end of the component code comp1 must be written: return data;

The component comp1 must be connected as follows:

$result = $APPLICATION->IncludeComponent(comp1, ...);

Now the data are located in the variable $result , and they can be transferred as incoming parameters into another component comp2.



Courses developed by Bitrix24