Bitrix Site Manager

Navigation chain

In this topic 

What is navigation chain

A navigation chain is the design element which aims to helps users navigate through the site. Navigation chain clearly shows the nesting depth of the current site section:

How to create

A common navigation chain includes site section titles with appropriate links applied to them. A site section title is defined in the service file .section.php, which can be found in the corresponding section. The following variables can be used in this file:

The following is an example of the .section.php file.

<?
$sSectionName = "Company profile";
$sChainTemplate = $_SERVER["DOCUMENT_ROOT"]."/en/about/chain_template.php";
?>

You can assign a title to the site section using the visual editor of the Site Explorer module. To do so, go to Site Explorer->Manage and open properties of the desired section. An alternative way is using control toolbar button Folder properties (in the public section).

In addition to the automatically displayed section titles, you can add arbitrary items to the navigation chain by calling CMain::AddChainItem.

Displaying navigation chain

Navigation chain is usually displayed in the prologue visual section by calling the method CMain::ShowNavChain using the delay function technology.

Design

Design of navigation chain is described in a special PHP file - navigation chain template. You can specify the path to this file explicitly when displaying the navigation chain. If the path is not specified, the following algorithm is used to locate the template file.

  1. Navigation chain items are collected starting from the site root, to the current section. For each section, the corresponding file .section.php is included. If this file has the variable $sChainTemplate initialised, its value is used as the path to the navigation chain template. When enumerating sections, every new value of this variable replaces the old one. In other words, the deeper a section lies in the hierarchy, the more important is its variable $sChainTemplate.
  2. If, after building a chain, the template path is still not defined, the following file is checked:

    /bitrix/templates/current site template ID/chain_template.php

    If the file exists, its path is used as the menu template path. Otherwise, the default file path is used:

    /bitrix/templates/.default/chain_template.php

When displaying the navigation chain, the navigation chain template is included every time an item is added. It follows that its main task is to provide the design of a single chain item.

The following are the main variables used in the navigation chain template.

The variables listed above store the HTML code describing the navigation chain design.

In addition, the following variables are available in the template.

Example of templates


<?
// simplest template displaying the standard chain

// HTML code displayed before chain
$sChainProlog = "";

// HTML code defining the design of a chain item
$sChainBody = "";
if (strlen($LINK)>0)
	$sChainBody .= "<a href=\"".$link."\" class='chainitem'>".$TITLE."</a>";
else
	$sChainBody .= "<font class='chainitem'>".$TITLE."</font>";

// HTML code displayed after the navigation chain
$sChainEpilog = "";
?>
<?
// template displaying the inverted navigation chain without links
// can be used in the <title> tag
// for better indexing by search engines

$sChainEpilog = "";

// if array is defined...
if (is_array($arCHAIN))
{
    // iterate on items
    reset($arCHAIN);
    foreach($arCHAIN as $item) 
    {
        // if first item...
        if (strlen($sChainEpilog)<=0)
            $sChainEpilog = $item["TITLE"];
        else // otherwise
            $sChainEpilog = $item["TITLE"]." :: ".$sChainEpilog;        
    }
}
?>

More information