Skip to content

Instantly share code, notes, and snippets.

@sartas
sartas / init.php
Created April 7, 2014 11:04
событие активации элемнета
AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("Handler", "OnBeforeIBlockElementUpdate"));
class Handler
{
// создаем обработчик события "OnBeforeIBlockElementUpdate"
function OnBeforeIBlockElementUpdate(&$arFields)
{
$iblock_id = 3;
/**
* vk likes
* @param $links
* @param $vk_app_id
* @return array
*/
function vk($links, $vk_app_id)
{
$vk_likes = array();
@sartas
sartas / menu
Created February 16, 2014 09:23
main menu
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
{
die();
} ?>
<nav class="main-nav">
<?
$cur_page = $APPLICATION->GetCurPage();
foreach ($arResult as $key => $arItem): ?>
<?php
/**
* User: marsel
* Date: 16.02.14
* Time: 11:56
*/
namespace bitrixlib;
require_once(dirname(__FILE__).'/query.php');
function news_date($time)
{
$date = new DateTime($time);
$out = array();
$out[] = $date->format('d');
$out[] = rus_month($date->format('m'), 1, 1);
$out[] = $date->format('Y');
@sartas
sartas / news_years_months.php
Created December 11, 2013 10:04
bitrix group by
<?php
//$useCache = true;
$useCache = false;
$cacheValid = false;
$this_iblock_id = (int)$this_iblock_id;
if ($useCache)
{
@sartas
sartas / bitrix_js_to_footer
Last active December 25, 2015 13:49
bitrix, js to fooer
@sartas
sartas / bitrix_attach
Created October 14, 2013 08:31
bitrix attache files
<?
require('phpmailer.php');
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
$a = $b = null;
$res = CEventMessage::GetList($a, $b, array('EVENT_NAME' => 'USER_QUESTION'));
$mess = $res->Fetch();
// news.list
// костыль для правильного кеширования, чтобы страницы с гет параметрами кешировались отдельно
global $PAGE_ID ;
$PAGE_ID = array();
if(isset($_GET['id'])){
$PAGE_ID['id']=$_GET['id'];
}
//
function plural($number, $suffix)
{
$keys = array(2, 0, 1, 1, 1, 2);
$mod = $number % 100;
$suffix_key = ($mod > 7 && $mod < 20) ? 2 : $keys[min($mod % 10, 5)];
return $suffix[$suffix_key];
}