Views: 12948
Last Modified: 10.10.2024

In this lesson we will review, stage by stage, the procedure for creating a page with different headers of the browser window and the page itself. Site template may require changes during this work.

  • Set a page header from the interface or using the function of $APPLICATION->SetTitle(“Page title”):
    <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
    $APPLICATION->SetTitle("Page title"); ?>
    ....
    <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"); ?>
    

  • Add additional header through interface or using the function of $APPLICATION->SetPageProperty('title','Browser title'):

    <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
    $APPLICATION->SetTitle("Page title"); 
    $APPLICATION->SetPageProperty('title','Browser title'); ?>
    ...
    <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"); ?>
    

    The function of $APPLICATION->SetPageProperty() in the system has a priority over the function of $APPLICATION->SetTitle(). That is why the browser and page headers will display the contents of the function exactly:

  • If different headers are to be used for page and web browser window, check the parameters of the CMain::ShowTitle() method displaying page header in the site template.

    Replace:

    $APPLICATION->ShowTitle()

    with:

    $APPLICATION->ShowTitle(false)

    In this case, the value of page property SetPageProperty('title','Browser title') will be ignored, and the header set by the function of SetTitle() will be used as a page header instead.


    Let us review the difference in operation of the function $APPLICATION->ShowTitle() with the false parameter using the following example, without changing the template code:

    <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
    $APPLICATION->SetTitle("Page title"); 
    $APPLICATION->SetPageProperty('title','Browser title'); 
    $APPLICATION->ShowTitle(); 
    <br>
    $APPLICATION->ShowTitle(false); ?>
    ....
    <?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
    



Courses developed by Bitrix24