How to optimally load articles with multiple nested properties into Bitrix InfoBlocks? Our site uses a self-hosted version of Bitrix Site Management with a ‘News’ InfoBlock. We are changing the content loading logic so that news articles can be assembled from individual paragraphs. Each paragraph can contain: text, image, video, photo gallery (5 different types total), quote, or paragraph formatting (with image on the right, left, or full width). Currently we are using composite properties (simai), but they are limited to 7 properties inside and do not support nested composite properties. We are considering using InfoBlock bindings, but it seems inconvenient. What alternative approaches or solutions exist for such tasks?
Optimal Loading of Articles with Multiple Nested Properties into Bitrix InfoBlocks Requires a Comprehensive Approach
Optimal loading of articles with multiple nested properties into Bitrix InfoBlocks requires a comprehensive approach that considers the limitations of standard solutions and offers alternative architectural approaches. For your task with news articles collected from various paragraph types, the most effective solutions will be those based on Highload blocks or custom data structures using InfoBlock element relationships.
Contents
- Analysis of Current Approach Limitations
- Alternative Content Structuring Approaches
- Highload Block Solution
- Custom Property Types and Their Implementation
- Performance Optimization for Loading
- Practical Comparison of Approaches
- Recommendations for Solution Selection
Analysis of Current Approach Limitations
Your use of SIMAI composite properties faces fundamental platform limitations. As noted in the SIMAI Framework documentation, a composite property allows combining several regular properties into a single string or multiple properties into a composite multiple property-table [2]. However, there are critical limitations:
- Limitation of 7 properties within a single composite property, which is insufficient for your structure with 5 content types plus formatting
- Lack of support for nesting composite properties, making it impossible to create multi-level paragraph structures
- Performance issues with a large number of elements, as composite properties don’t support composite database indexes for accelerating query operations
It’s important to note that for combined filters on non-multiple (single) properties, it’s now possible to manually create composite database indexes to accelerate query operations [1]. However, this only applies to InfoBlocks 2.0 and doesn’t solve the nesting problem.
Alternative Content Structuring Approaches
1. Using InfoBlock References
Although you consider this approach inconvenient, with proper implementation it can be the optimal solution. Instead of storing all paragraphs in a single element, you can create:
- “Paragraphs” InfoBlock with content types (text, image, video, etc.)
- Main “News” InfoBlock with references to paragraphs through a “Element Reference” property type
// Example of retrieving an article with paragraphs
$rsElement = CIBlockElement::GetList(
array(),
array(
"IBLOCK_ID" => $newsIblockId,
"ID" => $articleId
),
false,
false,
array("ID", "NAME", "PROPERTY_PARAGRAPHS")
);
while ($arElement = $rsElement->GetNext()) {
$paragraphs = $arElement["PROPERTY_PARAGRAPHS_VALUE"];
// Additional paragraph retrieval
}
2. Structured Data in a Single Property
For complex structures, you can use a single “String” property type with JSON structure:
{
"paragraphs": [
{
"type": "text",
"content": "Paragraph text",
"formatting": "left_image"
},
{
"type": "image",
"src": "/path/to/image.jpg",
"position": "right"
}
]
}
Highload Block Solution
The most productive approach for your task will be using Highload blocks [1]. This method allows you to create an optimal data structure without InfoBlock limitations:
Creating Highload Block Structure:
-
HLBlock_Paragraphs - for storing content types
- TYPE (content type)
- CONTENT (content depending on type)
- SORT (sequence number)
- NEWS_ID (reference to news)
-
HLBlock_MetaData - for additional formatting data
- PARAGRAPH_ID (link to paragraph)
- FORMAT_OPTIONS (JSON with formatting parameters)
Advantages of this approach:
- No limitations on the number of properties
- High performance when working with large data volumes
- Structural flexibility and ability to add new content types
- Native support for filtering and sorting
Custom Property Types and Their Implementation
If you prefer to stay within the InfoBlock framework, you can create your own property type [4]. As noted in the sources, “the article covers the process of creating a custom property for 1C Bitrix information blocks. Examples of implementing a multiple property are given” [4].
Algorithm for Creating Custom Property Type:
- Creating a property type class in the folder
/bitrix/php_interface/include/property_types/ - Implementing methods:
- GetUserTypeDescription()
- GetListRowValue()
- GetEditFormHTML()
- ConvertToDB()
class ParagraphPropertyType extends CUserTypeString {
function GetEditFormHTML($arProperty, $value, $strHTMLControlName) {
// Here implement a complex paragraph editor
return '<div class="paragraph-editor">' . $value . '</div>';
}
}
Performance Optimization for Loading
When working with complex data structures, performance optimization is critical:
1. Using Caching
// Caching paragraph retrieval
$cache = new CPHPCache();
$cacheId = 'article_paragraphs_' . $articleId;
$cachePath = '/article_paragraphs/';
if ($cache->InitCache($cacheTime, $cacheId, $cachePath)) {
$paragraphs = $cache->GetVars();
} else {
$paragraphs = getArticleParagraphs($articleId);
$cache->StartDataCache($cacheTime, $cacheId, $cachePath);
$cache->EndDataCache($paragraphs);
}
2. Optimizing Database Queries
- Using composite indexes for frequently used field combinations
- Lazy loading of paragraphs when displaying an article
- Pagination within complex structures
According to research on Bitrix website speed optimization, “images of InfoBlocks and other database entities can be compressed when generating component templates” [9]. This approach is particularly relevant for news articles with large amounts of media content.
Practical Comparison of Approaches
| Approach | Advantages | Disadvantages | Implementation Complexity |
|---|---|---|---|
| SIMAI composite properties | Easy configuration | Limitation of 7 properties, no nesting | Low |
| InfoBlock references | Flexibility, standard solutions | Requires more database queries | Medium |
| Highload blocks | High performance, no limitations | Requires API development | High |
| Custom property types | Full control over structure | Complexity of maintenance | High |
Recommendations for Solution Selection
Based on analysis of your task and platform limitations, I recommend the following strategy:
For small to medium projects:
- Use InfoBlock references with pre-loading of all paragraphs
- Implement caching at the application level
- Optimize images as part of the general website acceleration approach [9]
For high-load projects:
- Move the structure to Highload blocks for maximum performance
- Create a REST API for working with paragraphs
- Implement processing queue for media content
Temporary solution:
If you need to quickly solve the problem of the 7-property limitation, you can split the structure into multiple SIMAI composite properties [2], but this doesn’t solve the nesting problem and complicates maintenance.
Conclusion
Optimal loading of articles with multiple nested properties in Bitrix requires a comprehensive approach. Main recommendations:
- Highload blocks provide the greatest flexibility and performance for complex data structures
- InfoBlock references remain the most standard solution for moderate loads
- Custom property types give full control but require significant development investment
- Performance optimization through caching and indexing is critical for all approaches
For your task with news articles containing various content types, transitioning to Highload blocks with a specialized structure for storing paragraphs appears most promising. This will allow you to bypass composite property limitations and ensure the necessary performance.
Sources
- Creating and editing InfoBlock properties - 1C-Bitrix: Site Management
- SIMAI: Composite property for information blocks - 1C-Bitrix Marketplace
- Composite properties - SIMAI Framework
- Custom InfoBlock property type in 1C Bitrix - ProgClub
- Standard and custom properties in Bitrix - detailed overview - Intervolga
- Bitrix website speed optimization in 2022 - WEBTENSE
- SIMAI: Properties for information blocks - 1C-Bitrix Marketplace
- Standard properties of InfoBlock elements/sections in Bitrix - SIMAI
- SIMAI Framework - 1C-Bitrix Standards