News Section Setup on 1C-Bitrix
News section is one of the first things set up on fresh Bitrix, and one of the most often broken. Typical problems: URL duplication, cache doesn't clear on publish, images don't display in correct size. Let's go through setup from infoblock to pagination.
News Infoblock: Required Settings
Create infoblock of type news with symbol code news. Key parameters on creation:
-
BIZPROC = N— business processes for news are excessive, enabling slows writes -
VERSION = 2— property storage in separate tables (b_iblock_element_prop_s{id}), faster for large volumes -
INDEX_ELEMENT = Y,INDEX_SECTION = Y— for search -
DETAIL_PAGE_URL = /news/#ELEMENT_CODE#/— detail page URL via symbol code, not ID
Fill symbol code (CODE in b_iblock_element) automatically: in infoblock settings enable TRANSLIT_AUTOFIELD_NAME = Y. Generates transliteration from news name on save. Without it editors leave blank and Bitrix crashes to 404 on detail pages.
Infoblock properties for news:
-
SOURCE— source, typeString -
AUTHOR— author, typeUser Bindingor justString -
TAGS— tags, multipleString(or built-inTAGSfield)
Components: list and detail
The pair bitrix:news.list + bitrix:news.detail is standard. Place via composite bitrix:news component or separately.
bitrix:news.list parameters to watch:
IBLOCK_TYPE = news
IBLOCK_ID = <your infoblock id>
SORT_BY1 = ACTIVE_FROM
SORT_ORDER1 = DESC
CACHE_TYPE = A
CACHE_TIME = 3600
DISPLAY_DATE = Y
PAGER_SHOW = Y
PAGER_TEMPLATE = .default
Cache CACHE_TIME = 3600 with auto invalidation (CACHE_TYPE = A) is optimal. On news publish via CIBlockElement::Add() or admin interface Bitrix auto clears component cache. If not — check that BXClearCache isn't globally disabled in caching settings.
In list's template.php standard output set: $arItem["NAME"], $arItem["PREVIEW_TEXT"], $arItem["PREVIEW_PICTURE"], $arItem["DISPLAY_ACTIVE_FROM"]. For images Bitrix stores original in /upload/, resizes via CFile::ResizeImageGet() with write to /upload/resize_cache/.
Pagination and Friendly URLs
Pagination in bitrix:news.list works via GET-parameter PAGEN_1 (or custom name). Problem: Google indexing sees /news/?PAGEN_1=2 as duplicate URL. Solution: use pagination template with <link rel="next"> and <link rel="prev"> in <head> — add in component_epilog.php.
For friendly-URL pagination like /news/page/2/ need customization: component doesn't support out of box, implement via urlRewrite.php or template override.
RSS Feed
News section often needs RSS. rss module in Bitrix is bitrix:rss.export component. Configure like bitrix:news.list, generates valid RSS 2.0 or Atom. Mount on separate page /news/rss.php with content type application/xml.
With active caching RSS updates with delay — set CACHE_TIME for RSS page not more than 900 seconds or clear cache on publish via OnAfterIBlockElementAdd event handler.
Auto-Publishing and Scheduled News
Fields ACTIVE_FROM and ACTIVE_TO in b_iblock_element manage publication time. Element with future ACTIVE_FROM doesn't display in components with standard filtering. For auto-publish at exact time need agent (b_agent table), which regularly clears cache or checks publication — standard CIBlockAgent::CheckDiskQuota agent doesn't fit, write your own.







