-
What is Bitrix Framework?
-
Production Architecture
-
Production Architecture
-
Structure of files
-
Access Rights
-
A Site in Terms of Bitrix Framework
-
-
Processing Techniques
-
Core D7
-
Modules
-
Name Spaces
-
Core Parameter Setup
-
Exceptions
-
Events
-
Code Writing Rules
-
Applications and Context
-
Errors
-
ORM
-
API
-
Highloadblock
-
-
Design Integration
-
Using Access Rights
-
Site Design Template
-
Using message files for localization
-
Editable areas
-
Navigation tools
-
Advertisement
-
Managing Template Service Data
-
Editing Service Areas
-
Managing Page Encoding
-
Managing Document Header
-
Managing Metadata Values
-
CSS management
-
-
Setup of External Appearance of Additional Elements of the Site Design
-
-
Information Blocks
-
Working with Infoblocks Using Standard Means
-
Infoblocks 2.0
-
Action Plan in Case of Problems
-
Sorting
-
Work with Infoblocks through API
-
Examples
-
-
Components
-
Simple and composite components
-
Location of a Component in the System and Its Connection
-
Component Structure
-
Composite Component Structure
-
Component Description
-
Component Parameters
-
Component Templates
-
Support of Component Classes
-
result_modifier.php
-
component_epilog.php
-
Operation of a Composite Component in a SEF Mode
-
Frequent Errors
-
Component Caching
-
Working with Components
-
Template Customization
-
Component Customization
-
Creating Components
-
Additional Methods
-
Redefinition of Incoming Variables
-
User-Defined Templating Engines
-
Operation of a Composite Component in SEF Mode
-
Ways of Data Transmission among Components
-
A Simple Example of a Component Creation
-
Component Creation Example
-
TinyMCE Visual Editor Integration Component
-
Caching in own components
-
-
CUSTOM Parameter Type
-
More examples
-
Errors When Working with Components
-
-
-
Modules
-
Programming in Bitrix Framework
-
Golden Rules
-
The file init.php
-
UTF-8 or a National Encoding?
-
Working with Databases
-
Setup of SEF for URLs
-
Language Files
-
JS Library
-
Interface of the Control Panel Toolbar as Seen by a Developer
-
Some Theory
-
Performance
-
Security
-
Examples, tricks, and advice
-
Custom Fields
-
Gadgets
-
Project Testing
-
Project Quality Control
-
Debugging Web Applications
-
-
Push and Pull module
-
Version Control System
-
-
Multiple Sites
-
Introduction
-
Use of Multiple Site Version
-
How many sites can I create?
-
Language versions (mirrors)
-
Sharing visitors between sites
-
Configuring the multisite system
-
Working with the Data in a Multiple Site Configuration
-
Frequent Questions Arising When Working with a Multiple Site Configuration
-
-
Business Processes for Developer
-
Template of a Business Process
-
Business Process
-
Activities
-
Executing a business process activity using API
-
Arbitrary PHP Code in a Business Process
-
-
Additional Information and Examples
Sorting
Lesson 95 out of 253
Sometimes caching is bad. If we choose to cache a catalog with a multivariate filter in the conditions of dense website traffic, cache generation may exceed 200 MB per minute. Any disc quota limit will be filled fast enough. Problems with cleaning this cache may also occur. Deactivating such cache will reduce the number of writing operations.
Do not be afraid of creating indexes. It is impossible to say which indexes must be created in each particular case by default; each specific situation must be examined without fail. The tool Analyze indexes helps you do that (Settings > Performance > Database indexes > Analyze indexes).
One of the indexes most frequently used is the index by the list-based property. This index is intended for simple infoblocks. b_iblock_element_property - in this table property values are stored. So we index it: property value, its ID, and an element ID. When the list-based property filter is in place, creating such an index actually makes the query of MySQL to said table unnecessary because all of the query fields are available in the index.
Indexes are needed for specific sampling in specific projects. Depending on project architecture and logics, slow queries receive their own indexes, and they need such own indexes; often such indexes are composite.
Sorting Types
In the majority of functions and methods of the module of information blocks with list selection, filters admit different sorting types. Sorting type symbols shall be indicated directly before the name of the field to be sorted.
Types:
- (empty) – for string fields means mask search (in mask: "%" - an arbitrary number of any symbols, "_" - one arbitrary symbol); for non-string fields the search is "equal".
<? // find elements in which the name begins with "#" $res = CIBlockElement::GetList(Array(), Array("NAME"=>"#%")); // find elements with identifier 100 $res = CIBlockElement::GetList(Array(), Array("ID"=>"100")); ?>
- "!" - for strings – an expression that does not fall within a mask, or unequal (for other types of fields).
<? // find elements in which the name does not begin with "#" $res = CIBlockElement::GetList(Array(), Array("!NAME"=>"#%")); ?>
- "?" - using the logics, works only for string properties.
<? // find elements in which the name contains "One" or "Two" $res = CIBlockElement::GetList(Array(), Array("?NAME"=>"One | Two")); ?>
- "<" - less;
- "<=" - less or equal;
- ">" - more;
- ">=" - more or equal.
<? // find elements in which the name begins with "A" $res = CIBlockElement::GetList(Array(), Array(">=NAME"=>"A", "<NAME"=>"B")); // find elements with an identifier of more than 100 $res = CIBlockElement::GetList(Array(), Array(">ID"=>"100")); ?>
- "=" - equal;
- "!=" - non-equal.
<? // find elements in which the name is equal to "ELEMENT%1" $res = CIBlockElement::GetList(Array(), Array("=NAME"=>"ELEMENT%1")); ?>
- "%" - substring;
- "!%" - not a substring.
<? // find elements in which the name contains the percent symbol "%" $res = CIBlockElement::GetList(Array(), Array("%NAME"=>"%")); ?>
- "><" - between;
- "!><" - not between.
As an argument, these types of filters admit an array ("value FROM", "value TO")
<? // ind elements in which the name begins between "A" and "B" or between "D" and "E" $res = CIBlockElement::GetList(Array(), Array("><NAME"=>Array(Array("A", "B"), Array("D", "E")))); // find elements in which the activity start date is outside the year 2003 $res = CIBlockElement::GetList(Array(), Array("!><DATE_ACTIVE_FROM"=> Array(date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), mktime(0,0,0,1,1,2003)), date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), mktime(0,0,0,1,1,2004))))); ?>
Some Specific Cases of Sorting
$arFilter = array("PROPERTY_CML2_SCAN_CODE"=>false ) - is used to select all elements with an empty property; $arFilter = array("PROPERTY_CML2_SCAN_CODE"=>"" ) - is used to select all elements; $arFilter = array("PROPERTY_CML2_SCAN_CODE"=>"qwe" ) - during element sorting, the exact match of a property with the preset string is checked; $arFilter = array("?PROPERTY_CML2_SCAN_CODE"=>"qwe" ) - during element sorting, the availability of preset substring in a property is checked; $arFilter = array("!PROPERTY_CML2_SCAN_CODE"=>false ) - is used to select only elements with a property filled in; $arFilter = array("!PROPERTY_CML2_SCAN_CODE"=>"qwe" ) - during element sorting, the absence of the exact match with the preset string is checked; $arFilter = array("!?PROPERTY_CML2_SCAN_CODE"=>"qwe" ) - during element sorting, the absence of the preset substring in a property is checked.
Sorting Set Up to Display Related Elements
Task: Let us assume that there are 2 infoblocks that are interrelated by one of the properties. How should we set up the sorting so that among the infoblock elements only related elements can be displayed?
Solution:
<? $arrFilter = array(); $arrFilter['!PROPERTY_<property_code>'] = false; ?>
Sorting Set Up Using a "Date/Time" Type of Property
A "Date/time" type of property is stored as string in the format YYYY-MM-DD HH:MI:SS, That is why the value for sorting is formed as follows:
$cat_filter[">"."PROPERTY_available"] = date("Y-m-d");