Настройка языковой версии компонент news news.list news.detail на одном домене из одного инфоблока с языковыми свойствами _RU _EN. Рассмотрим на примере сайта где основной язык русский (в корне сайта), и второй язык английский в папке en. В первую очередь, вызов компонент осуществляется в каждой языковой папке.
\public_html\news\index.php — для вывода версии ru на странице новостей сайта
\public_html\en\news\index.php — для вывода версии en на странице новостей сайта
Содержимое index файла новостей en компонеты bitrix:news:
<?$APPLICATION->IncludeComponent( "bitrix:news", "news", array( "ADD_ELEMENT_CHAIN" => "N", "ADD_SECTIONS_CHAIN" => "N", "AJAX_MODE" => "N", "AJAX_OPTION_ADDITIONAL" => "", "AJAX_OPTION_HISTORY" => "N", "AJAX_OPTION_JUMP" => "N", "AJAX_OPTION_STYLE" => "Y", "BROWSER_TITLE" => "-", "CACHE_FILTER" => "N", "CACHE_GROUPS" => "Y", "CACHE_TIME" => "36000000", "CACHE_TYPE" => "A", "CHECK_DATES" => "Y", "COMPONENT_TEMPLATE" => "news", "DETAIL_ACTIVE_DATE_FORMAT" => "j F Y", "DETAIL_DISPLAY_BOTTOM_PAGER" => "Y", "DETAIL_DISPLAY_TOP_PAGER" => "N", "DETAIL_FIELD_CODE" => array( 0 => "", 1 => "", ), "DETAIL_PAGER_SHOW_ALL" => "Y", "DETAIL_PAGER_TEMPLATE" => "", "DETAIL_PAGER_TITLE" => "Страница", "DETAIL_PROPERTY_CODE" => array( 0 => "NAME_EN", 1 => "DETAIL_TEXT_EN", 2 => "", ), "DETAIL_SET_CANONICAL_URL" => "N", "DISPLAY_BOTTOM_PAGER" => "Y", "DISPLAY_DATE" => "Y", "DISPLAY_NAME" => "Y", "DISPLAY_PICTURE" => "Y", "DISPLAY_PREVIEW_TEXT" => "Y", "DISPLAY_TOP_PAGER" => "N", "HIDE_LINK_WHEN_NO_DETAIL" => "N", "IBLOCK_ID" => "14", "IBLOCK_TYPE" => "*****", "INCLUDE_IBLOCK_INTO_CHAIN" => "N", "LIST_ACTIVE_DATE_FORMAT" => "j F Y", "LIST_FIELD_CODE" => array( 0 => "", 1 => "", ), "LIST_PROPERTY_CODE" => array( 0 => "NAME_EN", 1 => "PREVIEW_TEXT_EN", 2 => "", ), "MESSAGE_404" => "", "META_DESCRIPTION" => "-", "META_KEYWORDS" => "-", "NEWS_COUNT" => "20", "PAGER_BASE_LINK_ENABLE" => "N", "PAGER_DESC_NUMBERING" => "N", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "N", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => "modern", "PAGER_TITLE" => "Новости", "PREVIEW_TRUNCATE_LEN" => "", "SEF_FOLDER" => "/en/news/", "SEF_MODE" => "Y", "SET_LAST_MODIFIED" => "N", "SET_STATUS_404" => "N", "SET_TITLE" => "N", "SHOW_404" => "N", "SORT_BY1" => "ACTIVE_FROM", "SORT_BY2" => "SORT", "SORT_ORDER1" => "DESC", "SORT_ORDER2" => "ASC", "STRICT_SECTION_CHECK" => "N", "USE_CATEGORIES" => "N", "USE_FILTER" => "N", "USE_PERMISSIONS" => "N", "USE_RATING" => "N", "USE_RSS" => "N", "USE_SEARCH" => "N", "USE_SHARE" => "N", "SEF_URL_TEMPLATES" => array( "news" => "", "section" => "", "detail" => "#ELEMENT_CODE#/", ) ), false );?>
Для каждого сайта вызывается своя компонент, где указываются соответствующие языковые свойства для списка новостей в параметре LIST_PROPERTY_CODE
Для детальной новости выбираются значения свойств в параметре DETAIL_PROPERTY_CODE
SEF_FOLDER — путь при переходе в новость
SET_TITLE — Чтобы убрать заголовок в детальной новости
Для корневого ru сайта будут:
"LIST_PROPERTY_CODE" => array( 0 => "NAME_RU", 1 => "PREVIEW_TEXT_RU", 2 => "", ), "SEF_FOLDER" => "/news/",
Настройка компоненты bitrix:news.list расположенной на главной странице
\public_html\local\templates\corp-template\bti\inc\en\main\news.php
\public_html\local\templates\corp-template\bti\inc\ru\main\news.php
<?$APPLICATION->IncludeComponent( "bitrix:news.list", "news", array( "ADD_ELEMENT_CHAIN" => "Y", "ADD_SECTIONS_CHAIN" => "N", "AJAX_MODE" => "N", "AJAX_OPTION_ADDITIONAL" => "", "AJAX_OPTION_HISTORY" => "N", "AJAX_OPTION_JUMP" => "N", "AJAX_OPTION_STYLE" => "Y", "BROWSER_TITLE" => "-", "CACHE_FILTER" => "N", "CACHE_GROUPS" => "Y", "CACHE_TIME" => "36000000", "CACHE_TYPE" => "A", "CHECK_DATES" => "Y", "DETAIL_ACTIVE_DATE_FORMAT" => "d.m.Y", "DETAIL_DISPLAY_BOTTOM_PAGER" => "Y", "DETAIL_DISPLAY_TOP_PAGER" => "N", "DETAIL_FIELD_CODE" => array( 0 => "", 1 => "", ), "DETAIL_PAGER_SHOW_ALL" => "Y", "DETAIL_PAGER_TEMPLATE" => "", "DETAIL_PAGER_TITLE" => "Страница", "DETAIL_PROPERTY_CODE" => array( 0 => "", 1 => "", ), "DETAIL_SET_CANONICAL_URL" => "N", "DISPLAY_BOTTOM_PAGER" => "Y", "DISPLAY_DATE" => "Y", "DISPLAY_NAME" => "Y", "DISPLAY_PICTURE" => "Y", "DISPLAY_PREVIEW_TEXT" => "Y", "DISPLAY_TOP_PAGER" => "N", "HIDE_LINK_WHEN_NO_DETAIL" => "N", "IBLOCK_ID" => "14", "IBLOCK_TYPE" => "*****", "INCLUDE_IBLOCK_INTO_CHAIN" => "N", "LIST_ACTIVE_DATE_FORMAT" => "", "LIST_FIELD_CODE" => array( 0 => "", 1 => "", ), "LIST_PROPERTY_CODE" => array( 0 => "", 1 => "", 2 => "", ), "MESSAGE_404" => "", "META_DESCRIPTION" => "-", "META_KEYWORDS" => "-", "NEWS_COUNT" => "8", "PAGER_BASE_LINK_ENABLE" => "N", "PAGER_DESC_NUMBERING" => "N", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "N", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => "modern", "PAGER_TITLE" => "Новости", "PREVIEW_TRUNCATE_LEN" => "", "SEF_MODE" => "Y", "SET_LAST_MODIFIED" => "N", "SET_STATUS_404" => "N", "SET_TITLE" => "N", "SHOW_404" => "N", "SORT_BY1" => "ACTIVE_FROM", "SORT_BY2" => "SORT", "SORT_ORDER1" => "DESC", "SORT_ORDER2" => "ASC", "STRICT_SECTION_CHECK" => "N", "USE_CATEGORIES" => "N", "USE_FILTER" => "N", "USE_PERMISSIONS" => "N", "USE_RATING" => "N", "USE_RSS" => "N", "USE_SEARCH" => "N", "USE_SHARE" => "N", "COMPONENT_TEMPLATE" => "news", "SEF_FOLDER" => "/news/", "FILTER_NAME" => "", "FIELD_CODE" => array( 0 => "", 1 => "", ), "PROPERTY_CODE" => array( 0 => "NAME_RU", 1 => "PREVIEW_TEXT_RU", 2 => "", ), "DETAIL_URL" => "", "ACTIVE_DATE_FORMAT" => "d.m.Y", "SET_BROWSER_TITLE" => "N", "SET_META_KEYWORDS" => "N", "SET_META_DESCRIPTION" => "Y", "PARENT_SECTION" => "", "PARENT_SECTION_CODE" => "", "INCLUDE_SUBSECTIONS" => "Y" ), false );?>
В \public_html\local\templates\corp-template\components\bitrix\news\news\bitrix\news.detail\.default\result_modifier.php и в \public_html\local\templates\corp-template\components\bitrix\news.list\news\result_modifier.php переопределяем стандартные свойства на свои, чтобы не менять шаблон.
<?if(!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED!==true) die(); if( $arResult['ITEMS'] ): $l = strtoupper(LANGUAGE_ID); // Языковые версии foreach($arResult['ITEMS'] as $k=>$e) { // NAME if( $e['PROPERTIES']['NAME_'.$l]['VALUE'] ) $arResult['ITEMS'][$k]['NAME'] = $e['PROPERTIES']['NAME_'.$l]['VALUE']; // PREVIEW if( $e['PROPERTIES']['PREVIEW_TEXT_'.$l]['VALUE'] ) $arResult['ITEMS'][$k]['PREVIEW_TEXT'] = $e['PROPERTIES']['PREVIEW_TEXT_'.$l]['~VALUE']['TEXT']; } endif?>
А в \public_html\local\templates\corp-template\components\bitrix\news\news\bitrix\news.detail\.default\component_epilog.php добавляем:
$APPLICATION->AddChainItem($arResult['NAME'], $arResult['DETAIL_PAGE_URL']);
для вывода в навигационной цепочке в детальной новости верное языковое название новости.
Для отображения заголовка в списке новостей на странице, нужный заголовок прописываем в шаблон. !очень плохо так делать