-
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
Work examples
Lesson 196 out of 253
Filtering
Custom fields of sections can participate in filtering.
$sec_Filter= array( "IBLOCK_ID" => $IBLOCK_ID, "DEPTH_LEVEL" => "2", "!UF_ARC_PAGES" => "" );
All sections with the property UF_ARC_PAGES set will be selected.
Filtering by value of a custom property:
$arSFilter ['=UF_USERS_PROPERTY'] =$users_property_value;
Sorting
Sorting by custom fields of sections:
$arSort = array( "UF_RATING"=>"asc", "sort"=>"asc" );
Obtaining Values
The method GetList of the appropriate class is used to obtain the value of a custom field.
The value of a custom field for the user with ID=2 can be obtained as follows:
$rsUser = CUser::GetByID($user); $arUser = $rsUser->Fetch(); $required value = $arUser['custom field code'];
In order to obtain a value of a custom field of a specific user, where the field type is a line, the method GetList of the class CUser should be used. In this case, an array with the key SELECT must be submitted as a fourth argument. The values of this key are the list of codes of the custom properties we are looking for.
global $USER; $arFilter = array("ID" => $USER->GetID()); $arParams["SELECT"] = array("UF_USER_CARD_CODE"); $arRes = CUser::GetList($by,$desc,$arFilter,$arParams); if ($res = $arRes->Fetch()) { echo $res["UF_USER_CARD_CODE"]; }
If the type of a custom field is a list, then the method GetList of the class CUserFieldEnum should be used to obtain the value (or values, if a multiple choice is possible).
global $USER; $arFilter = array("ID" => $USER->GetID()); $arParams["SELECT"] = array("UF_LIST_TASK"); $arRes = CUser::GetList($by,$desc,$arFilter,$arParams); if ($res = $arRes->Fetch()) { foreach ($res["UF_LIST_TASK "] as $id) { $rsRes= CUserFieldEnum::GetList(array(), array( "ID" => $id, )); if($arResult = $rsRes->GetNext()) echo $arGender["VALUE"]; } }
If a list of all the values of the custom field of a list-type USER object, the following code should be used:
global $USER_FIELD_MANAGER; $arFields = $USER_FIELD_MANAGER->GetUserFields("USER"); $obEnum = new CUserFieldEnum; $rsEnum = $obEnum->GetList(array(), array("USER_FIELD_ID" => $arFields["UF_LIST_TASK "]["ID"])); while($arEnum = $rsEnum->GetNext()){ echo $arEnum["VALUE"]; }
To select a value of a custom field from a section of the information block, the method CIBlockSection:GetList can be used:
$aSection = CIBlockSection::GetList( array(), array( 'IBLOCK_ID' => 3, 'CODE' => 'test_section', ), false, array( 'UF_DEV2DAY_FIELD' ) )->Fetch();
Obtaining a value of a file-type custom field of a specific section of the infoblock:
$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => "1"), false, $arSelect = array("UF_*")); while ($arResult = $rsResult -> GetNext()) { print "" . print_r($arResult, true) . ""; }
Since custom fields can be used with sections of an information block as well as any other entities, the class CUserTypeManager shall be used to select values by entity identifier. An instance of this class is already located in the global variable $USER_FIELD_MANAGER.
global $USER_FIELD_MANAGER; $aSection = CIBlockSection::GetList( array(), array( 'IBLOCK_CODE' => 'shop_news', 'CODE' => 'test_section', ) )->Fetch(); if( !$aSection ) { throw new Exception( 'The section is not found' ); } $aUserField = $USER_FIELD_MANAGER->GetUserFields( 'IBLOCK_3_SECTION', $aSection['ID'] ); // array
As a result, we will obtain an array containing all the information about the field and its value for a specific object.