Last Modified: 19.05.2022
Complex components have an in-built SEF generating function. These components always have an input parameter
SEF_MODE, which can accept values
N. When parameter
N, the component operates with actual links and passes all parameters using query's standard HTTP parameters. For example:
When the parameter
Y, the component generates and processes links based on templates. For example, it can recognize and process the link as follows:
, even if the parameter is located in the file
When the parameter
Y, the component must have the parameter
SEF_FOLDER, containing path to folder handled by the component. This path can may match with actual path and may not. For example, the component bitrix:catalog, connected in the file
/fld/cat.php can have the specified parameters
SEF_MODE = Y and
SEF_FOLDER=/catalog/. Then component will respond to queries at the path
/catalog/.... By default, editor must set a current actual path to edited file.
Complex component that can operate in SEF mode, must have a defined set of default path templates. For example, complex component bitrix:catalog can have a defined array as follows:
$arDefaultUrlTemplatesSEF = array(
"list" => "index.php",
"section" => "section.php?IBLOCK_ID=#IBLOCK_ID#&SECTION_ID=#SECTION_ID#",
"element" => "element.php?ELEMENT_ID=#ELEMENT_ID#"
These path templates can be redefined using the complex component input parameter
SEF_URL_TEMPLATES, containing new array with all path templates or their segments.
Upon saving a page in editor with the component, operating in SEF mode, the system creates or updates an
urlrewrite record. For example, urlrewrite system creates or updates the record type when saving the file
/fld/cat.php, containing the component bitrix:catalog, switched to SEF mode with the parameter
"CONDITION" => "#^/catalog/#",
"ID" => "bitrix:catalog",
"PATH" => "/fld/cat.php"
CONDITION writes the value of parameter
SEF_FOLDER, framed with symbols "#^" and "#";
ID writes the name of component;
PATH writes the actual path to file to be saved.
When the record with such
ID already exist, it's updated, if doesn't - it's added.
Upon querying a non-existent page, the urlrewrite run-time searches a corresponding record by
CONDITION and forwards control to the
Based on template paths, component at the
PATH page identifies the requested page and restores variables, hidden within the path.
Mandatory requirement to the set of template paths for this component: each path template must be unique without accounting parameters and variables. This requirement must be checked upon saving a page in visual editor.
That is, set of path templates
"section" => "section/#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#",
"element" => "element/#ELEMENT_ID#.php"
is permissible and set of paths
"section" => "#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#",
"element" => "#ELEMENT_ID#.php"
is not permitted.