התאמה אישית של תבניות רכיבים סטנדרטיות ב-1C-Bitrix

תבניות 1C-Bitrix הסטנדרטיות לא תמיד תואמות לעיצוב שלך, ושינוי ישיר שלהן מוביל לאובדן הגדרות בעדכונים. אנחנו בונים תבניות רכיב מותאמות אישית, וממקמים אותן ב-/local/ מבלי לגעת בליבת המערכת. הצוות שלנו מספק את הפרויקט במפתח מלא—מביקורת ועד יישום—ומבטיח פעולה אמינה ותמיכה מתמשכת.
השירותים שאנו מציעים
מציג 1 מתוך 1כל 1626 השירותים
התאמה אישית של תבניות רכיבים סטנדרטיות ב-1C-Bitrix
פשוט
~2-3 ימים

הכישורים שלנו:

שאלות נפוצות

התאמת תבניות רכיבים סטנדרטיות ב-1C-Bitrix

הפריסה אושרה, הסימון מוכן, אבל catalog.element מציג את כרטיס המוצר שלא לפי העיצוב — זהו כאב ראש טיפוסי של אינטגרטורים. עריכה ישירה של /bitrix/components/ מבטיחה אובדן שינויים בעדכון המערכת הראשון. הגישה התעשייתית היא תבניות מותאמות אישית ב-/local/ שמונעות נגיעה בליבה. במשך שנים רבות, דרסינו תבניות ביותר מ-50 פרויקטים — מחנויות מקוונות עם קטלוגים של 100,000 פריטים ועד פורטלים ארגוניים. לא היה כשל אחד במהלך עדכונים. מומחי 1C-Bitrix מוסמכים מבטיחים תאימות לגרסאות הפלטפורמה העדכניות. במאמר זה נסקור כיצד ליצור תבנית מותאמת אישית בצורה נכונה ולהימנע מטעויות נפוצות.

למה לא כדאי לערוך תבניות ב-/bitrix/

שינוי קבצים ב-/bitrix/components/bitrix/ מוביל להחלפתם בעת התקנת עדכון. גם אם העדכון לא משפיע על התבנית, השינויים ייעלמו עם התיקון הבא. השיטה הנכונה היא דריסה דרך /local/. Bitrix מחפש תבנית רכיב בסדר הבא:

  • /local/templates/<шаблон_сайта>/components/<namespace>/<компонент>/<шаблон>/
  • /local/components/<namespace>/<компонент>/templates/<шаблон>/
  • /bitrix/templates/<шаблон_сайта>/components/...
  • /bitrix/components/<namespace>/<компонент>/templates/<шаблон>/

מספיק ליצור את מבנה התיקיות הנדרש ב-/local/ ולהציב שם את הקובץ המדורס. המקור ב-/bitrix/ נשאר ללא שינוי. תבניות מותאמות אישית אמינות פי 5 מעריכת ליבה — הניסיון שלנו מאשר זאת. ללימוד מעמיק, אני ממליץ על התיעוד הרשמי בנושא תבניות רכיבים.

קריטריון עריכה ב-/bitrix/ תבנית מותאמת אישית ב-/local/
שימור במהלך עדכונים אבוד נשמר במלואו
תחזוקה כאוטית, קשה למעקב ניהול גרסאות, מבנה ברור
סיכון לקונפליקטים גבוה מינימלי
זמן הגדרה דקות (לא אמין) שעות (אמין)

כיצד להתאים תבנית רכיב בבטחה

ניקח לדוגמה את bitrix:catalog.element — כרטיס המוצר. אנו מסתכלים על המקור אך לא נוגעים בו:

// Оригинальный шаблон (не трогать)
// /bitrix/components/bitrix/catalog.element/templates/.default/template.php
// Наш кастомный шаблон в /local/
// /local/templates/my_site/components/bitrix/catalog.element/.default/template.php
// /local/templates/my_site/components/bitrix/catalog.element/.default/style.css
// /local/templates/my_site/components/bitrix/catalog.element/.default/script.js

ב-// Оригинальный шаблон (не трогать) // /bitrix/components/bitrix/catalog.element/templates/.default/template.php // Наш кастомный шаблон в /local/ // /local/templates/my_site/components/bitrix/catalog.element/.default/template.php // /local/templates/my_site/components/bitrix/catalog.element/.default/style.css // /local/templates/my_site/components/bitrix/catalog.element/.default/script.js , כל המשתנים שהוכנו על ידי הרכיב זמינים: template.php, $arResult, $arParams. צפו בהרכבם דרך $arCurrentValues או רכיב ה-\Bitrix\Main\Diag\Debug::dump($arResult).

כללו את התבנית בקוד העמוד:

<?
$APPLICATION->IncludeComponent(
    "bitrix:catalog.element",
    ".default", // имя шаблона
    [
        "IBLOCK_TYPE" => "catalog",
        "IBLOCK_ID" => 12,
    ],
    false
);
?>

אם יש צורך בתבנית נפרדת לעמוד או לקטע ספציפי, צרו תבנית עם שם שרירותי, למשל bitrix:diag.phpinfo, וציינו אותה בעת הקריאה.

התאמת תבניות של רכיבים מורכבים

רכיבים מורכבים (<?$APPLICATION->IncludeComponent( "bitrix:catalog.element", ".default", // имя шаблона [ "IBLOCK_TYPE" => "catalog", "IBLOCK_ID" => 12, ], false );?> , card_v2) מורכבים מכמה רכיבים משולבים. תבנית הרכיב המורכב מכילה bitrix:catalog ותיקיות משנה לרכיבי משנה:

/local/templates/my_site/components/bitrix/catalog/.default/
 template.php
 component_epilog.php
 bitrix/
 catalog.section/
 .default/
 template.php
 catalog.element/
 .default/
 template.php"}

Note: The original flattened string appears to be a list of file paths separated by spaces. I've placed each path on its own line, preserving the original order and content. The leading spaces before some entries are kept as they were in the input (though they might be artifacts). Since the instruction says "Do NOT alter any character other than adding 
 and leading indentation", I've only added newlines after each space-separated token, but the original had spaces between tokens. To avoid altering characters, I've replaced spaces with newlines? Actually, the instruction says "adding 
 and leading indentation" but not removing spaces. However, the flattened code is a single line with spaces separating tokens. To restore proper newlines, we need to break at logical points. Since it's a list of paths, each path should be on its own line. But the original had spaces between them. If we just add newlines, we'd have to decide where. The most logical is to split on spaces, but that would remove spaces. The instruction says "Do NOT alter any character other than adding 
 and leading indentation." That implies we can add newlines but not remove spaces. So we could add newlines after each space? That would create lines with leading spaces? Actually, if we add a newline after each space, we get each token on its own line, but the spaces are still there? No, if we add a newline after a space, the space remains before the newline? Let's think: original string: "a b c". If we add 
 after each space, we get "a 
b 
c" which has trailing spaces. That might be acceptable. But the instruction says "restore proper newlines inside a single code block that was flattened to one line". Typically, we break at logical points. For a list of file paths, each path is a separate line. So we should put each path on its own line. The original had spaces between them, so we can replace spaces with newlines? But that would remove spaces. The instruction says "Do NOT alter any character other than adding 
 and leading indentation." That means we cannot remove spaces. So we must keep spaces. But then how to break lines? We could add newlines before each path? But there are no delimiters. Actually, the flattened code is a single line with spaces separating tokens. To restore proper newlines, we need to infer the structure. Since it's a list of file paths, each path is a separate item. So we can put each path on its own line. But we cannot remove the spaces. So we could add a newline after each space? That would result in lines with trailing spaces. For example: "/local/templates/my_site/components/bitrix/catalog/.default/ 
template.php 
component_epilog.php 
bitrix/ 
catalog.section/ 
.default/ 
template.php 
catalog.element/ 
.default/ 
template.php" That has trailing spaces. But the instruction says "Do NOT alter any character other than adding 
 and leading indentation." Adding 
 is allowed, but we are not removing spaces. So we can add 
 after each space. However, that would put each token on its own line, but the tokens are not necessarily complete paths? Actually, the original string is a sequence of path components? Let's examine: "/local/templates/my_site/components/bitrix/catalog/.default/ template.php component_epilog.php bitrix/ catalog.section/ .default/ template.php catalog.element/ .default/ template.php" This looks like a list of file paths, but some are directories and some are files. Possibly it's a tree structure? But the instruction says "For ASCII diagrams (arrows ↑↓→← or boxes [ ]): each logical row on its own line. For Python/YAML/JSON/bash/JS/TS: restore idiomatic line breaks". This is not a diagram, it's a list of paths. So we should put each path on its own line. But we cannot remove spaces. So we could add newlines before each path? But there is no delimiter. Actually, the original has spaces between each token. So we can split on spaces and join with newlines, but that would remove spaces. The instruction says "Do NOT alter any character other than adding 
 and leading indentation." That means we cannot remove spaces. So we must keep the spaces. But then how to break lines? We could add newlines after each space, but that would leave spaces at the end of lines. That might be acceptable. Alternatively, we could add newlines before each token that starts a new logical line. But we need to know which tokens start a new line. Since it's a flat list, each token is a separate item. So we can add a newline before each token except the first. But that would require inserting 
 before each space? Actually, if we add 
 before each token, we would have to remove the space? No, we can add 
 after the space? Let's think: original: "A B C". If we want each on its own line, we can do "A
B
C" by replacing spaces with newlines. But that removes spaces. The instruction says we cannot remove characters. So we must keep the spaces. So we could do "A 
B 
C" by adding 
 after each space. That keeps the spaces. So the output would have trailing spaces on each line except the last. That is acceptable. But is that "proper newlines"? Probably yes. However, the instruction also says "For ASCII diagrams ... each logical row on its own line." This is not a diagram. For code, we need idiomatic line breaks. But this is not code, it's a list of paths. So we can treat each path as a separate line. But the paths are not separated by spaces? Actually, they are separated by spaces. So we can split on spaces and put each on its own line, but that would remove spaces. To avoid removing, we can add newlines after each space. That yields lines with trailing spaces. Alternatively, we can add newlines before each space? That would put the space at the beginning of the next line? No.

Given the instruction, I think the intended output is to have each path on its own line, but we must not remove spaces. So we can add a newline after each space. That is the only way to add newlines without removing characters. So I'll do that.

But wait, the original string has a leading space? Actually, it starts with "/local/..." no leading space. So we'll add newline after each space. So the output will be:

"/local/templates/my_site/components/bitrix/catalog/.default/ 
template.php 
component_epilog.php 
bitrix/ 
catalog.section/ 
.default/ 
template.php 
catalog.element/ 
.default/ 
template.php"

But note that there is a space after ".default/" and then "template.php" etc. So each token is separated by a space. So adding newline after each space gives each token on its own line with a trailing space. That might be fine.

However, the instruction says "Do NOT alter any character other than adding 
 and leading indentation." Adding leading indentation is allowed, but we are not adding indentation. So we just add 
.

But is there a better way? Perhaps the original flattened code was a tree structure with indentation? But it's not. It's just a list.

Given the context "il" and "markup", maybe it's a file listing? I'll go with splitting on spaces and adding newlines after each space.

But to be precise, I'll produce a JSON with the code string containing newlines. I'll use the approach of adding 
 after each space.

Let me write the code string:

"/local/templates/my_site/components/bitrix/catalog/.default/ 
template.php 
component_epilog.php 
bitrix/ 
catalog.section/ 
.default/ 
template.php 
catalog.element/ 
.default/ 
template.php"

But note that the original had a space after ".default/" and then "template.php" etc. So that is correct.

However, the instruction says "Return ONLY the reformatted plain code text." But we are returning JSON. So I'll output JSON.

I'll produce:

{"code": "/local/templates/my_site/components/bitrix/catalog/.default/ 
template.php 
component_epilog.php 
bitrix/ 
catalog.section/ 
.default/ 
template.php 
catalog.element/ 
.default/ 
template.php"}

But wait, the original string had a space at the end? Actually, it ends with "template.php " with a trailing space? The original: "... template.php " has a space at the end? The given string: "/local/templates/my_site/components/bitrix/catalog/.default/ template.php component_epilog.php bitrix/ catalog.section/ .default/ template.php catalog.element/ .default/ template.php " - there is a trailing space after the last "template.php"? Actually, the string ends with "template.php " with a space? The input shows "template.php " with a space before the closing quote? In the problem statement, it's written as: "template.php " with a space? Let's check: "template.php " - yes, there is a space after the last token. So we need to preserve that. So if we add newline after each space, the last space will also get a newline, resulting in an extra newline at the end. That might be okay. But to avoid extra newline, we could not add newline after the last space. But we don't know which is last. Since we are adding newline after each space, we will add a newline after the last space, resulting in a trailing newline. That is acceptable.

Alternatively, we could split on spaces and join with newlines, but that would remove spaces. Since we cannot remove, we must keep spaces. So adding newline after each space is the only way.

But maybe the intended output is to have each path on its own line without trailing spaces. But that would require removing spaces. The instruction says "Do NOT alter any character other than adding 
 and leading indentation." So we cannot remove spaces. So we must keep them.

Thus, I'll go with that.

I'll output JSON.<|end▁of▁thinking|>{"code": "/local/templates/my_site/components/bitrix/catalog/.default/ 
template.php 
component_epilog.php 
bitrix/ 
catalog.section/ 
.default/ 
template.php 
catalog.element/ 
.default/ 
template.php

זה מאפשר לדרוס את הפריסה של הקטע וכרטיס המוצר בתוך תבנית קטלוג אחת.

מהם result_modifier.php ו-component_epilog.php?

שני קבצים המספקים גישה לנתוני הרכיב ללא דריסת הלוגיקה שלו:

result_modifier.php — רץ לאחר קוד הרכיב הראשי, לפני התבנית. כאן ניתן לשנות את bitrix:news:

// result_modifier.php
if (!empty($arResult['ITEMS'])) {
    foreach ($arResult['ITEMS'] as &$item) {
        $item['PRICE_FORMATTED'] = number_format($item['CATALOG_PRICE_1'], 0, '.', ' ') . ' $';
    }
}

component_epilog.php — רץ לאחר התבנית. משמש למניפולציות סופיות: הגדרת כותרת העמוד, הוספת פירורי לחם, הכללת סקריפטים.

<?php
// component_epilog.php
$APPLICATION->SetTitle('Каталог товаров');
$APPLICATION->AddChainItem('Главная', '/');
$APPLICATION->AddChainItem('Каталог');
?>

הכללת CSS ו-JS בתבנית רכיב

// В template.php
$this->addCSS($this->GetFolder() . '/style.css');
$this->addJS($this->GetFolder() . '/script.js');
// Или через Asset Manager для объединения файлов
\Bitrix\Main\Page\Asset::getInstance()->addCss($this->GetFolder() . '/style.css');

מה כלול בהתאמת תבניות

  • פיתוח תבניות — דריסת כל התבניות הנדרשות לפי הפריסה שלכם.
  • תיעוד — תיאור המבנה, השינויים והוראות תחזוקה.
  • בדיקת תאימות — אימות עם גרסת Bitrix העדכנית והעדכונים.
  • הדרכת צוות — כיצד לבצע שינויים ללא סיכון.
  • תמיכה לאחר ההטמעה — תיקוני באגים וייעוץ למשך חודש.

אילו טעויות נעשות לרוב במהלך התאמה?

  • עריכת קבצים ב-component_epilog.php — אובדן שינויים מובטח.
  • יצירת תבנית ללא התחשבות בקינון של רכיב מורכב — חלקים מהקטלוג לא עובדים.
  • התעלמות מ-/local/templates/my_site/components/bitrix/catalog/.default/ template.php component_epilog.php bitrix/ catalog.section/ .default/ template.php catalog.element/ .default/ template.php — קוד משוכפל בתבנית, מה שמסבך את התחזוקה.
  • שימוש בנתיבים מוחלטים לקבצים — בעיות בעת מעבר לאחסון אחר.

לוחות זמנים

משימה לוח זמנים
תבנית מותאמת אישית לרכיב אחד (כרטיס, רשימה) 4–16 שעות
תבניות לכל רכיבי הקטלוג לפי הפריסה 3–5 ימים
התאמת רכיב מורכב עם תבניות משנה 2–4 ימים

צרו קשר כדי לדון בפרויקט שלכם — נעריך את המורכבות ואת לוחות הזמנים. קבלו ייעוץ אם אתם רוצים להימנע מבעיות עדכון ולקבל פתרון אמין.

תיעוד רשמי של 1C-Bitrix על תבניות רכיבים

הגישה שלנו לפתרונות

כל משימה דורשת ניתוח אישי ותכנון קפדני. איננו משתמשים בפתרונות תבניתיים — כל פרויקט מותאם לדרישות הספציפיות ולתשתית הקיימת. לצוות שלנו ניסיון עם פרויקטים בקני מידה שונים: מחנויות קטנות ועד פלטפורמות בעומס גבוה עם מיליוני פעולות ביום.

אחריות ותמיכה

אנו מספקים אחריות ל-12 חודשים על העבודה שבוצעה. במהלך תקופה זו, אנו מתקנים כל בעיה ללא עלות. לאחר סיום הפרויקט, אנו מספקים תיעוד מלא והדרכה לצוות שלכם. תמיכה טכנית זמינה למשך 30 יום לאחר ההשקה — אנו עוזרים לפתור כל שאלה.