Custom Pages in 1C-Bitrix: D7 Controllers and Routing

When Standard Pages Aren't Enough: A Real Problem On one project, we needed to create an interface for managing affiliate programs with flexible rules. Standard Bitrix components didn't fit—complex business logic with custom access rights and external API integration was required. Manually buildi

Our competencies:

Frequently Asked Questions

When Standard Pages Aren't Enough: A Real Problem

On one project, we needed to create an interface for managing affiliate programs with flexible rules. Standard Bitrix components didn't fit—complex business logic with custom access rights and external API integration was required. Manually building admin files would have led to code duplication and update issues. We chose the D7 approach—controllers with routing, built-in CSRF protection, and modular architecture. Development took 5 days instead of the expected 2 weeks, saving a significant budget portion due to reduced rework time. Our engineers hold "1C-Bitrix" certificates and have worked with D7 since its release. Reach out to us for similar results.

Why Choose MVC Controller in Bitrix?

Controllers eliminate boilerplate: access checks via prefilters, automatic CSRF, JSON support, session handling. In a classic admin file, you manually call bitrix_sessid_post() and check rights. Our team's experience (over 50 Bitrix projects) shows that switching to controllers reduces development time by 1–2 days per page. We guarantee stability during kernel updates—all prefilters and routes are code-managed, not file-based. Additionally, maintenance costs drop by 20–30% due to a uniform structure.

How to Create a Custom D7 Page? Two Approaches

Classic admin file (/bitrix/admin/my_page.php)—the simplest option for auxiliary tools. It requires no routing setup, but all CSRF and permission checks are on the developer.

<?php require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"); use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; Loader::includeModule('my.module'); // Permission check if (!$APPLICATION->IsAdminPage() || !\CMain::GetUserRight("main") >= "S") { $APPLICATION->AuthForm("Access denied"); } $APPLICATION->SetTitle("My Tool"); require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"); // Page content ?> <form method="post" action="<?= $APPLICATION->GetCurPage() ?>"> <?= bitrix_sessid_post() ?> <!-- form fields --> <input type="submit" value="Execute"> </form> <?php require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"); 

MVC via Controller—the right path for pages with logic.

namespace MyProject\Controllers; use Bitrix\Main\Engine\Controller; use Bitrix\Main\Engine\ActionFilter; class ReportController extends Controller { public function configureActions(): array { return [ 'getReport' => [ 'prefilters' => [ new ActionFilter\Authentication(), new ActionFilter\HttpMethod(['GET', 'POST']), new ActionFilter\Csrf(), ], ], ]; } public function getReportAction(int $periodDays = 30): array { $data = \MyProject\Services\ReportService::build($periodDays); return ['data' => $data, 'total' => count($data)]; } } 

The controller automatically processes requests, checks the CSRF token, and returns JSON. The route is registered via \Bitrix\Main\Routing\Router::getInstance()->add().

Step-by-Step Guide: Creating a Controller for a Custom Page

  1. Define the namespace and controller class, extending \Bitrix\Main\Engine\Controller.
  2. Implement configureActions(), specifying prefilters for rights and CSRF.
  3. Create action methods (e.g., getListAction, saveAction) with parameter validation.
  4. Register the route in local/routes.php or via Router::add().
  5. Configure access rights with ActionFilter\Permission or custom filters.
  6. Integrate UI: use CAdminList for listings, CAdminForm for forms.

What Using MVC Controller in Bitrix Brings

Controllers eliminate boilerplate: access checks via prefilters, automatic CSRF, JSON support, session handling. In a classic admin file, you manually call bitrix_sessid_post() and check rights. Our team's experience (over 50 Bitrix projects) shows that switching to controllers reduces development time by 1–2 days per page. We guarantee stability during kernel updates—all prefilters and routes are code-managed, not file-based.

Pagination and UI: Integration with D7

For data lists use \Bitrix\Main\UI\PageNavigation:

use Bitrix\Main\UI\PageNavigation; $nav = new PageNavigation('page'); $nav->allowAllRecords(false) ->setPageSize(20) ->initFromUri(); $result = \MyProject\Storage\OrderLogTable::getList([ 'select' => ['*'], 'order' => ['ID' => 'DESC'], 'count_total' => true, 'offset' => $nav->getOffset(), 'limit' => $nav->getLimit(), ]); $nav->setRecordCount($result->getCount()); 

For admin list pages, use ready UI via CAdminList and CAdminFilter.

Approach Comparison: Admin File vs Controller

Criteria Classic Admin File MVC Controller
Security Manual CSRF Built-in prefilters
Maintenance Harder Modular
Development Speed Fast for simple tasks Faster for complex ones
Kernel Updates Risk of breakage Stability

Timelines and Cost

Task Type Estimated Time
Simple admin page (form + data display) 2–3 days
Page with list, pagination, filter, actions 4–7 days
Full CRUD interface for custom entity with rights and logs 1.5–2.5 weeks

Cost is calculated individually. On average, time savings in maintenance amount to 20–30% compared to the classic approach. Learn more about D7 advantages in the official 1C-Bitrix documentation and on Wikipedia.

What's Included in the Work

  • Architecture design (controllers, routes, templates)
  • Business logic implementation on D7 with caching and access rights
  • Integration with Bitrix UI (CAdminList, filters, pagination)
  • API and code structure documentation
  • Access handover (repository, database, admin panel)
  • Training for the support team
  • 3-month warranty on functionality
Additional security note In D7 controllers, you can configure prefilters for access control, e.g., `ActionFilter\Authentication` and `ActionFilter\Csrf`, eliminating manual errors. Controllers also support session handling and automatic XSS protection.

A custom D7 page is not a replacement for the component system. It is a tool for tasks that don't fit the standard model: admin tools, import interfaces, dashboards with aggregated data. When written correctly, they don't conflict with kernel updates. Get a consultation for your project—we'll assess complexity and timeline within 1 day. Book a free demo.