Setting up a news section on 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1189
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    813
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

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, type String
  • AUTHOR — author, type User Binding or just String
  • TAGS — tags, multiple String (or built-in TAGS field)

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.