Работа с шаблонами SEO свойств инфоблоков

Модуль расширенного управления меню для битрикс

Июнь 13, 2018

Теги: Инфоблоки

Работа с шаблонами SEO-свойств инфоблоков при помощи классов "\Bitrix\Iblock\InheritedProperty".

Изменить SEO шаблоны для инфоблока с идентификатором в переменной $iblockId:


$ipropIblockTemplates = new \Bitrix\Iblock\InheritedProperty\IblockTemplates($iblockId);

$templates $ipropIblockTemplates->findTemplates();
$newTemplates=array('SECTION_META_TITLE'=>$templates['SECTION_META_TITLE']['TEMPLATE']." дополнительный текст - {=this.Name}");
$ipropIblockTemplates->set($newTemplates);

Изменить SEO шаблоны для раздела с идентификатором в переменной $iblockSectionId:


$ipropSectionTemplates = new \Bitrix\Iblock\InheritedProperty\SectionTemplates($iblockId,$iblockSectionId);

$templates $ipropSectionTemplates->findTemplates();
$newTemplates=array('SECTION_META_TITLE'=>$templates['SECTION_META_TITLE']['TEMPLATE']." дополнительный текст - {=this.Name}");
$ipropSectionTemplates->set($newTemplates);

Изменить SEO шаблоны для элемента с идентификатором в переменной $iblockElementId:


$ipropElementTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($iblockId,$iblockElementId);

$templates $ipropElementTemplates->findTemplates();
$newTemplates=array('ELEMENT_META_TITLE'=>$templates['ELEMENT_META_TITLE']['TEMPLATE']." дополнительный текст - {=this.Name}");
$ipropElementTemplates->set($newTemplates);

Удалить SEO шаблоны для инфоблока с идентификатором в переменной $iblockId:


$ipropIblockTemplates = new \Bitrix\Iblock\InheritedProperty\IblockTemplates($iblockId);

$ipropIblockTemplates->delete();

Удалить SEO шаблоны для раздела с идентификатором в переменной $iblockSectionId:


$ipropSectionTemplates = new \Bitrix\Iblock\InheritedProperty\SectionTemplates($iblockId,$iblockSectionId);

$ipropSectionTemplates->delete();

Удалить SEO шаблоны для элемента с идентификатором в переменной $iblockElementId:


$ipropElementTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($iblockId,$iblockElementId);

$ipropElementTemplates->delete();

См. также:

← Переход к списку