Skip to content

Instantly share code, notes, and snippets.

@ildarkhasanshin
Last active November 6, 2016 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ildarkhasanshin/50dbd5b10c83d1a005613c791d63d783 to your computer and use it in GitHub Desktop.
Save ildarkhasanshin/50dbd5b10c83d1a005613c791d63d783 to your computer and use it in GitHub Desktop.
bitrix settitle
bitrix
settitle
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
global $APPLICATION;
$APPLICATION->AddChainItem($arResult['NAME']);
if (isset($arResult['new_title'])) {
$APPLICATION->SetTitle($arResult['new_title']);
$APPLICATION->SetPageProperty("title", $arResult['new_title']);
}
<?if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
die();
}
global $APPLICATION;
$cp = $this->__component;
if (is_object($cp)) {
$cp->arResult['new_title'] = $cp->arResult['SECTION']['NAME'];
$cp->arResult['IS_OBJECT'] = 'Y';
$cp->SetResultCacheKeys(array('new_title', 'IS_OBJECT'));
$arResult['new_title'] = $cp->arResult['new_title'];
$arResult['IS_OBJECT'] = $cp->arResult['IS_OBJECT'];
$APPLICATION->SetTitle($cp->arResult['new_title']); // не будет работать на каждом хите: отработает только первый раз, затем будет все браться из кеша и вызова $APPLICATION->SetTitle() не будет. Поэтому изменение title делается в component_epilog, который выполняется на каждом хите
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment