Bitrix Site Manager

Delay functions

Delay functions enable to specify the page title, navigation chain items, CSS, control toolbar buttons, meta tags etc. by calling functions within the page body and emit the return values of these functions in the prologue, that is, place these values in the code generated earlier.

This technology has been developed mainly for use in components, which are usually placed in the page body but may want to set the page title, add items to navigation chain, add buttons to the control toolbar etc.

The delay functions technology is used in the public section only. It is not intended for use in the administrative section.

How it works

This technology works by the following algorithm.

  1. All the PHP script output is buffered.
  2. If a script calls one of the following functions: (or any other function for which delaying is enabled), the following operations are performed:
    1. the entire buffered output is stored in the next element of the stack A;
    2. an empty element is added to the stack A in which the result of the delay function execution is stored later;
    3. name of the delay function is stored in the stack B;
    4. the buffer empties and the buffering starts again.
    Thus, the stack A stores the entire page content split into sections. This stack also contains empty elements to be filled with the delay function execution results.

    The stack B stores names and parameters of the delay functions, in the order they appear in the code.

  3. When the script is about to finish execution, the epilogue service section performs the following actions:
    1. all the delay functions stored in the stack B are executed consequently;
    2. their results are placed in the previously allocated elements of the stack A;
    3. contents of the stack A is merged (concatenated) and displayed.

Therefore, this technology enables to fragment the page content splitting it into sections using functions that allow delaying execution of other functions. At the end of the page, all delay functions are executed consequently and their results are inserted in spots previously allocated in the fragmented page content. Then, all the fragmented content is merged, sent to the output stream and dispatched to a client's browser.

Consideration must be given to the fact that no operation may be performed on results of the functions that may cause other functions to be delayed. For example:

$page_title = $APPLICATION->ShowTitle(); // returns nothing
if (strlen($page_title)<=0)
    $page_title = "Default title";
This code is not functional because all delay functions are executed at the end of the page, in the epilogue service section.

Functions involved in this technology

Name of the delaying function Delays execution of these functions Additionally involved functions
CMain::ShowTitle CMain::GetTitle CMain::SetTitle
CMain::ShowCSS CMain::GetCSS CMain::SetTemplateCSS
CMain::ShowNavChain CMain::GetNavChain CMain::AddChainItem
CMain::ShowProperty CMain::GetProperty CMain::SetPageProperty
CMain::ShowMeta CMain::GetMeta CMain::SetPageProperty
CMain::ShowPanel CMain::GetPanel CMain::AddPanelButton

See Also