Documentation

ParseComponentPath

mixed
ParseComponentPath(
 string folder404 ,
 array arUrlTemplates ,
 array & arVariables [,
 string requestURL]
);

The method supports CNC mode in complex components. Static method.

This method returns code for complex component path based on folder in which the component operates, as well as array of path templates and current requested page. Additionally, this method restores those variables that were created via the path.

Parameters

ParameterDescription
folder404 Path that is used by complex component to operate in CNC mode. This path is passed in the input parameter $arParams["SEF_FOLDER"].
arUrlTemplates Array of path templates of complex component for CNC mode. This array is specified in the code of complex component and can be fully or partially be re-defined via input parameter. $arParams["SEF_URL_TEMPLATES"].
arVariables Variable that returns variables, restored from the requested path (based on the found path template).
requestURL Requested path. By default equals $APPLICATION->GetCurPage(). Optional from version 5.1.8.

Returned value

If the template is not found, its code is returned, otherwise empty string is returned.

Example

// if the array of path templates looks as follows
$arUrlTemplates = array(
	"list" => "index.php",
	"element" => "#IBLOCK_ID#/#ELEMENT_ID#.php?SID=#SECTION_ID#"
);
// input parameter SEF_FOLDER equals /company/news/
// requested address equals to /company/news/15/7653.php?SID=28

// then after method is called
$arVariables = array();
$page = 
    CComponentEngine::ParseComponentPath($arParams["SEF_FOLDER"], 
                                         $arUrlTemplates, $arVariables);

// the variable $page will have an "element" string
// (corresponding template code)
// and array $arVariables will look as follows
$arVariables = array(
	"IBLOCK_ID" => 15,
	"ELEMENT_ID" => 7653
)

Note Path must be specified without slash, specifically #IBLOCK_ID#/ and not the /#IBLOCK_ID#/. Otherwise returns false.

See Also

  • Complex component structure
  • Input variable aliases
  • CComponentEngine::MakeComponentUrlTemplates


  • © «Bitrix24», 2001-2024
    Up