Compound components is capable of generating search engine friendly URL's.
Each compound component has an input parameter SEF_MODE, which can be Y or N.
If SEF_MODE is N, the component handles physical links and passes all parameters via an HTTP request. For example:
If SEF_MODE is Y, the component generates and handles links using templates. For example, the following link is valid:
even if the component resides in /fld/cat.php.
If SEF_MODE is Y, another parameter SEF_FOLDER must be passed to the component. This parameter contains path to the folder in which the component runs. This path can be the same as the physical path, or it can be different. For example: a component «bitrix:catalog» activated in /fld/cat.php can have the parameters SEF_MODE = Y and SEF_FOLDER=/catalog/. In this case, the component will respond to requests containing /catalog/.... By default, the editor should provide the current physical path to a file being edited.
A compound component that functions in SEF mode must be provided with a set of default path templates. For example, the following array can be defined for the compound component «bitrix:catalog»:
$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 SEF_URL_TEMPLATES, which contains an array of all path templates or their portions.
When saving a page containing SEF component, the editor creates or updates a urlrewrite record. For example, when saving /fld/cat.php containing the «bitrix:catalog» component set to work in SEF mode with SEF_FOLDER=/catalog/, the urlrewrite system creates or updates a record similar to:
array( "CONDITION" => "#^/catalog/#", "ID" => "bitrix:catalog", "PATH" => "/fld/cat.php" ),
Here, CONDITION contains a value of SEF_FOLDER enclosed in «#^» and «#»; ID contains the component name, and PATH contains physical path to the file being saved. If a record with the specified PATH and ID already exists, it is updated; otherwise, a new record is created.
At run time, when a non-existing page is requested, urlrewrite searches for an appropriate record by CONDITION and passes control to a page specified in PATH.
The component running on a page to which PATH points finds the requested page and restores variables from the path.
"section" => "section/#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#", "element" => "element/#ELEMENT_ID#.php"are valid, but this array:
"section" => "#SECTION_ID#.php?IBLOCK_ID=#IBLOCK_ID#", "element" => "#ELEMENT_ID#.php"is invalid.
|© 2001-2007 Bitrix||Bitrix Site Manager|