Documentation

ShowNavChain

CMain::ShowNavChain(
 mixed path = false,
 int NumFrom = 0, 
 mixed NavChainPath = false
)

The method shows the navigation chain.

This method uses the delayed functions technology that allows, among other things, adding items into the navigation chain (inside a component, for example) after the site prologue was emitted.

If you do not need to show navigation chain on a page, simply initialize the "NOT_SHOW_NAV_CHAIN" page property with "Y":

$APPLICATION->SetPageProperty("NOT_SHOW_NAV_CHAIN", "Y");
The method has in-buit support for this property.

Non-static method.

Parameters

, pass an array in the following format:
ParameterDescription
path Path for which the navigation chain is to be built. In case of multiple sites, if the DOCUMENT_ROOT of the site is different (specified in the "Path to web server root folder" field in the site settings), the array of the following type must be passed in this parameter:
array("site ID", "path")
Optional parameter; false by default, which means the current path.
NumFrom Number of item starting from which the navigation chain will be built. Items of navigation chain are numbered starting from zero.
Optional parameter. By default value is "0".
NavChainPath Path to navigation chain template.
Optional parameter. The default value is false, which implies searching for the navigation chain template using the algorithm described in the Navigation chain section.

See Also

  • CMain::AddChainItem
  • CMain::GetNavChain

    Examples of use

    <?
    // display navchain on the current page
    // starting from the first item 
    // using the template "chain_template.php"
    // located in either "/bitrix/templates/<текущий шаблон сайта>/", 
    // or "/bitrix/templates/.default/".
    $APPLICATION->ShowNavChain();
    ?>
    <?
    // display navchain on the current page 
    // starting from the second item 
    // using the template chain_template_bottom.php
    $APPLICATION->ShowNavChain(false, 2, "/bitrix/templates/.default/chain_template_bottom.php");
    ?>

    Example of the navigation chain template:

    <?
    // file /bitrix/templates/.default/chain_template.php
    
    $sChainProlog = "";   // HTML before the navchain
    $sChainBody = "";     // navchain item
    $sChainEpilog = "";   // HTML after the navchain
    
    // separator
    if ($ITEM_INDEX > 0)
       $sChainBody = "<font class=\"chain\">&nbsp;/&nbsp;</font>";
    
    // if the link exists
    if (strlen($LINK)>0)
    {
        // display link
        $sChainBody .= "<a href=\"".$LINK."\" class=\"chain\">".htmlspecialchars($TITLE)."</a>";
    }
    else // otherwise
    {
        // text
        $sChainBody .= "<font class=\"chain\">".htmlspecialchars($TITLE)."</font>";
    }
    ?>


  • © «Bitrix24», 2001-2024