Answer the question
In order to leave comments, you need to log in
Generation of meta tags, how to implement?
Hello!
To specify metadata and h1 (for sections), I created additional fields.
Added properties for product cards.
It is necessary to implement auto-generation of metadata for those sections/products for which they are not registered in new fields.
figured out how to get field values for sections:
if(0 < intval($arResult["VARIABLES"]["SECTION_ID"])) {
$arFilter["ID"] = $arResult["VARIABLES"]["SECTION_ID"];
} elseif("" != $arResult["VARIABLES"]["SECTION_CODE"]) {
$arFilter["=CODE"] = $arResult["VARIABLES"]["SECTION_CODE"];
}
$arSelect = array("UF_META_T", "UF_META_K", "UF_META_D", "UF_H1");
$rsSections = CIBlockSection::GetList(array(), $arFilter, false, $arSelect);
if($arSection = $rsSections->Fetch()) {
$_h1_ = $arSection["UF_H1"];
$_title_ = $arSection["UF_META_T"];
$_desc_ = $arSection["UF_META_D"];
$_keyw_ = $arSection["UF_META_K"];
}
Answer the question
In order to leave comments, you need to log in
In component_epilog, setPageProperty() works if your data reaches this file.
Do not forget about the cache and the need to remove data from it:
$this->setResultCacheKeys([
'YOUR_PARAM',
]);
$APPLICATION->AddBufferContent('ShowCondTitle');
function ShowCondTitle()
{
global $APPLICATION;
if (!$APPLICATION->GetTitle())
return "Стандартная страница";
else
return $APPLICATION->GetTitle();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question