Skip to content

Instantly share code, notes, and snippets.

@SpiritAmalthea
SpiritAmalthea / bitrix_js_core.js
Created October 4, 2025 11:04
События JS #bitrix
Получение списка всех событий в системе
В файле /bitrix/js/main/core/core.js
находим: BX.onCustomEvent(eventObject, eventName, arEventParams, secureParams);
console.log(eventName, arEventParams);
или
value: function emit(eventName, event) {
console.log(eventName, event); //тут логируем
@SpiritAmalthea
SpiritAmalthea / form_errors.js
Created September 23, 2022 10:46
form errors #JavaScript
success: function(data) {
if (!data.error){
var result_html = '';
$(result_html).insertAfter('#calc-form');
}
else {
$.each(data.errorFieldNames, function(key, val) {
//$('input[name="'+val+'"]').parent().parent().addClass('has-error');
//$('textarea[name="'+val+'"]').stop().animate({borderColor:"#E82C0C"}, 2000);
});
В данный момент варианта 2:
1. Разместить в начало компонента news.list выставление заголовка header('X-Bitrix24-Page: dynamic');
2. Размещать блок на странице магазина, а не сайта (страницы магазинов не кешируются)
@SpiritAmalthea
SpiritAmalthea / word_endings
Created October 2, 2020 20:16
Окончание слов #php
<?
$partNumText = $k%10==1&&$k%100!=11?' участник':($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?' участника':' участников');
?>
@SpiritAmalthea
SpiritAmalthea / cache_clear
Created April 30, 2019 14:25
очистка кеша инфоблока #bitrix
CIBlock::clearIBlockTagCache(1);
@SpiritAmalthea
SpiritAmalthea / explode_words.php
Created March 31, 2019 09:57
Разбить строку не разбивая при этом слова
$arrayOutput = Array();
$arrayWords = explode(' ', $arResLead["POST"]);
$maxLineLength = 45;
$currentLength = 0;
$index = 0;
foreach ($arrayWords as $word) {
// +1 because the word will receive back the space in the end that it loses in explode()
@SpiritAmalthea
SpiritAmalthea / mysql_set_autoincriment
Created March 12, 2019 12:49
mysql auto incriment set to value #MySQL
ALTER TABLE tablename AUTO_INCREMENT = 1
@SpiritAmalthea
SpiritAmalthea / getrequest.js
Created February 8, 2019 09:19
get request paramas in javascript
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
@SpiritAmalthea
SpiritAmalthea / file_download.php
Created January 18, 2019 07:52
файл на загрузку #bitrix
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?>
<?
global $USER;
if (!$USER->IsAuthorized() && !empty($_GET["id"])) header('Location: /login/');
else{
$file = CFile::GetFileArray($_GET["id"]);
$time = time();
$file_name = $time.'_'.str_replace(" ","_", $file['ORIGINAL_NAME']);
@SpiritAmalthea
SpiritAmalthea / unique.js
Created December 5, 2018 11:47
javascript object unique #jquery #unique
function unique(list) {
var result = [];
$.each(list, function(i, e) {
if ($.inArray(e, result) == -1) result.push(e);
});
return result;
}