Views: 3088 (Data available since 06.02.2017)
Navigation chain is connected in the site design template using the component Breadcrumb (bitrix:breadcrumb). Any number of templates, i.e. designs, may be set for these components. All of them are stored in the component folder /bitrix/components/bitrix/breadcrumb/templates/<template name>/. All the new templates will be displayed in the component settings. Thus, a navigation chain design template may be set for each site template. The structure of the navigation chain display template is similar to the menu display template.
Navigation chain and its design template are managed in the same way as when working with other 2.0 components. Using control button in the site edit mode you can easily access the component parameter change form or copy the component template and then edit it.
Building Navigation Chain and Developing Its External Appearance:
- Navigation chain points are gathered starting from site root and ending with the current section. The file .section.php should be connected for each section. If this file has the variable of $sChainTemplate initiated, its value will be used as a path to the navigation chain template. While going through sections, each subsequent value of this variable overrides the previous one. Thus, the “deeper” the section is in the site section hierarchy, the more “important” its variable $sChainTemplate becomes.
- If the path to the template is not determined after points of the navigation chain have been collected, the existence of the file is checked:
If such a file exists, the path to it is adopted as the path to the navigation chain template. Otherwise, the default value is used:
/bitrix/templates/current site template ID/chain_template.php
If navigation chain is displayed, the navigation chain template will be connected each time at the next point of the chain. That is why its main task is to provide for the external appearance of only one point of the chain.
The main variables used in the template are as follows:
- $sChainProlog - is the HTML code displayed before the navigation chain;
- $sChainBody - is the HTML code which determines external appearance of one point of the navigation chain;
- $sChainEpilog - is the HTML code displayed after the navigation chain;
- $strChain - is the HTML code of the entire navigation chain collected by the time of template connection.
All variables shown will store HTML code determining the external appearance of the navigation chain.
In addition, the following additional variables will be available in the template:
- $TITLE is a header of a point of the navigation chain;
- $LINK is a link on a point of the navigation chain;
- $arCHAIN a copy of array of elements of the navigation chain;
- $arCHAIN_LINK a link to array of elements of the navigation chain;
- $ITEM_COUNT the number of array elements of the navigation chain;
- $ITEM_INDEX a sequential number of a point of the navigation chain.
Example of the navigation chain component template:
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$strReturn = '<ul class="breadcrumb-navigation">';
for($index = 0, $itemSize = count($arResult); $index < $itemSize; $index++)
if($index > 0)
$strReturn .= '<li><span> > </span></li>';
$title = htmlspecialcharsex($arResult[$index]["TITLE"]);
if($arResult[$index]["LINK"] <> "")
$strReturn .= '<li><a href="'.$arResult[$index]["LINK"].'" title="'.$title.'">'.$title.'</a></li>';
$strReturn .= '<li>'.$title.'</li>';
$strReturn .= '</ul>';
When connecting the navigation chain using the function ShowNavChain()
, its template may be additionally set for a separate site section.
To do so, the variable $sChainTemplate must be determined directly in the file .section.php where the complete path to the navigation chain display template is set. Example:
$sChainTemplate = "/bitrix/templates/demo/chain_template.php"
The navigation chain template may also be set when using the function ShowNavChain() as one of the parameters of the function.