Last active
November 6, 2016 12:05
-
-
Save ildarkhasanshin/50dbd5b10c83d1a005613c791d63d783 to your computer and use it in GitHub Desktop.
bitrix settitle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bitrix | |
settitle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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