Answer the question
In order to leave comments, you need to log in
How to make a 404 error for news in Bitrix?
There is a physical section - NEWS.
In it we call the component:
$APPLICATION->IncludeComponent(
"bitrix:news.list",
"articles",
array(
"ACTIVE_DATE_FORMAT" => "d.m.Y",
"ADD_SECTIONS_CHAIN" => "Y",
"AJAX_MODE" => "Y",
"AJAX_OPTION_ADDITIONAL" => "",
"AJAX_OPTION_HISTORY" => "Y",
"AJAX_OPTION_JUMP" => "N",
"AJAX_OPTION_STYLE" => "Y",
"CACHE_FILTER" => "N",
"CACHE_GROUPS" => "Y",
"CACHE_TIME" => "36000000",
"CACHE_TYPE" => "A",
"CHECK_DATES" => "Y",
"DETAIL_URL" => "",
"DISPLAY_BOTTOM_PAGER" => "Y",
"DISPLAY_DATE" => "N",
"DISPLAY_NAME" => "Y",
"DISPLAY_PICTURE" => "Y",
"DISPLAY_PREVIEW_TEXT" => "Y",
"DISPLAY_TOP_PAGER" => "N",
"FIELD_CODE" => array(
0 => "ID",
1 => "CODE",
2 => "NAME",
3 => "PREVIEW_TEXT",
4 => "PREVIEW_PICTURE",
5 => "",
),
"FILTER_NAME" => "",
"HIDE_LINK_WHEN_NO_DETAIL" => "N",
"IBLOCK_ID" => "15",
"IBLOCK_TYPE" => "custom",
"INCLUDE_IBLOCK_INTO_CHAIN" => "N",
"INCLUDE_SUBSECTIONS" => "Y",
"MESSAGE_404" => "",
"NEWS_COUNT" => "12",
"PAGER_BASE_LINK_ENABLE" => "N",
"PAGER_DESC_NUMBERING" => "Y",
"PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
"PAGER_SHOW_ALL" => "N",
"PAGER_SHOW_ALWAYS" => "N",
"PAGER_TEMPLATE" => ".default",
"PAGER_TITLE" => "Советы",
"PARENT_SECTION" => "",
"PARENT_SECTION_CODE" => "",
"PREVIEW_TRUNCATE_LEN" => "",
"PROPERTY_CODE" => array(
0 => "",
1 => "",
),
"SET_BROWSER_TITLE" => "Y",
"SET_LAST_MODIFIED" => "N",
"SET_META_DESCRIPTION" => "Y",
"SET_META_KEYWORDS" => "Y",
"SET_STATUS_404" => "Y",
"SET_TITLE" => "Y",
"SHOW_404" => "Y",
"SORT_BY1" => "SORT",
"SORT_BY2" => "ID",
"SORT_ORDER1" => "DESC",
"SORT_ORDER2" => "ASC",
"COMPONENT_TEMPLATE" => "articles"
),
false
);
Answer the question
In order to leave comments, you need to log in
I read the posts, they say - you need to register a certain function in init.php
AddEventHandler('main', 'OnEpilog', '_Check404Error', 1); // Вешаем обработчик на окончание рендера
function _Check404Error() {
if (((defined('ERROR_404') && ERROR_404 == 'Y') || preg_match('~404~ius', CHTTP::GetLastStatus())) && !defined('ADMIN_SECTION')) { // смотрим - пришел ли штатный define или в отправляемом статусе есть 404 - то закрываем буфферы и инклюдим 404 из корня сайта
global $APPLICATION;
$APPLICATION->RestartBuffer();
$APPLICATION->AddChainItem("404");
include $_SERVER['DOCUMENT_ROOT'] . SITE_TEMPLATE_PATH . '/header.php';
include $_SERVER['DOCUMENT_ROOT'] . '/404.php';
include $_SERVER['DOCUMENT_ROOT'] . SITE_TEMPLATE_PATH . '/footer.php';
}
}
just the same, if the SHOW_404 == Y parameter and you entered the url incorrectly, then the 404.php page should be called (unless otherwise specified in the settings).
There are also Error document entries in htaccess.
From the question, the essence is not very clear to be honest.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question