Views: 2695 (Data available since 06.02.2017)
The SEF generating function is embedded in the composite components. These components always have an input parameter SEF_MODE that admits the values Y and N. If SEF_MODE is equal to N the component works with physical links and transfers all of the parameters through the standard parameters of HTTP query. For example:
If the SEF_MODE parameter is equal to Y then the component generates and processes links based on templates. For example, the component can “understand” and process the link:
/catalog/section/371.php?IBLOCK_ID=12 even if the component itself is located in the file
If the SEF_MODE parameter is equal to Y, the component must also have the SEF_FOLDER, parameter that must contain a path to the folder with which the component works. This path may either coincide with the physical path or not. For example, the parameters SEF_MODE = Y and SEF_FOLDER=/catalog/ may be set up in the component bitrix:catalog connected in the file
/fld/cat.php. In this case, the component will respond to queries using the path /catalog/.... By default, the editor must set up the current physical path to the editable file.
A composite component that can work in an SEF mode must have a set of path templates by default. For example, in the composite component bitrix:catalog the following array can be defined:
$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 input parameter of the composite component SEF_URL_TEMPLATES that contains a new array of all path templates or a part of them.
When saving a page with a component operating in an SEF mode, the editor creates or updates an entry in the urlrewrite system. For example, when saving the file
/fld/cat.php containing the component bitrix:catalog switched to an SEF mode with the parameter SEF_FOLDER=/catalog/, the urlrewrite system creates or updates an entry similar to:
"CONDITION" => "#^/catalog/#",
"ID" => "bitrix:catalog",
"PATH" => "/fld/cat.php"
- The value of the parameter SEF_FOLDER is written in CONDITION between the symbols #^ and #;
- The name of the component is written in ID;
- The physical path to the file saved is written in PATH.
If an entry with such PATH and ID already exists, it gets updated and, if not, it is added.
In run-time, upon receiving a query for a physically nonexistent page, the urlrewrite mechanism searches for the appropriate entry according to CONDITION and transfers control to the page PATH.
The component located on the PATH page identifies the requested page based on path templates and recovers variables hidden in the path.
Attention! The mandatory requirement for the set of path templates for this component is the uniqueness of each path template, except parameters and variables. It must be verified when saving the page in the visual editor.
For example, a set of path templates:
"section" => "section/#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#",
"element" => "element/#ELEMENT_ID#.php"
is acceptable, and a set of path templates:
"section" => "#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#",
"element" => "#ELEMENT_ID#.php"
is not acceptable.