This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Получить ID текущего раздела (например, в шаблоне компонента каталога) | |
print_r($arResult["VARIABLES"]["SECTION_ID"]); | |
2. Проверка авторизован ли как Администратор | |
<?php | |
global $USER; | |
if ($USER->IsAdmin()) echo "<pre>"; print_r($arResult["VARIABLES"]["SECTION_ID"]); echo "</pre>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
body { | |
margin: 0; | |
font-family: Arial, Helvetica, sans-serif; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Дата создания элемента" | |
Значение данной даты понятно по названию. Она имеет следующий вид отображения (записи) DD.MM.YYYY HH:MI:SS, где DD - день месяца, MM - месяц, YYYY - год, HH - час (в формате 24), MI - минуты, SS - секунды. Или в php имеют формат 'd.m.Y H:i:s'. | |
Соответственно для фильтрации по дате создания, надо указывать дату согласно данному формату. | |
Например | |
$arFilter['>=DATE_CREATE'] = '19.11.2018 09:00:00'; | |
или | |
$arFilter['>=DATE_CREATE'] = date('d.m.Y H:i:s'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FrameBuffered - класс для буферизированных динамических областей. Именно объект этого класса создаётся когда в шаблоне компонента мы вызываем $this->createFrame(). С помощью этого класса удобно создавать заглушки динамических областей. | |
$frame = new \Bitrix\Main\Page\FrameBuffered("my_dynamic"); // или $this->createFrame() в шаблоне | |
$frame->begin(); | |
// Содержание динамической области | |
$frame->beginStub(); | |
// Заглушка | |
$frame->end(); | |
Метод удобный, но в нём не работают отложенные функции. Для обхода этой ситуации создан второй класс: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Создать свой шаблон компонента постраничной навигации bitrix:system.pagenavigation | |
<?if($arResult["NavPageCount"] > 1):?> | |
<?if ($arResult["NavPageNomer"]+1 <= $arResult["nEndPage"]):?> | |
<? | |
$plus = $arResult["NavPageNomer"]+1; | |
$url = $arResult["sUrlPathParams"] . "PAGEN_1=" . $plus | |
?> | |
<div class="load_more" data-url="<?=$url?>"> | |
Показать еще | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Усовершенствованные методы буферизации в шаблоне позволяют более не использовать CBitrixComponentTemplate::EndViewTarget() ввиду того, что конец шаблона вызывает завершение буферизации автоматически. | |
Описанные ниже способы по своей сути похожи на Включаемые области. Только Включаемая область это файл подключаемый в шаблоне сайта, а указанные методы - это область, которая формируется в коде шаблона. | |
Можно использовать как в шаблоне сайта, так и в шаблоне компонента. | |
Теперь есть поддержка стандартного кеширования в компонентах. | |
template.php: | |
<?$this->SetViewTarget("sidebar");?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Для этого в header.php шаблона сайта добавляем следующий скрипт, предварительно подключив jQuery: | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(document).ready( | |
function(){ | |
function getBasketHTML(html) | |
{ | |
txt = html.split('<!--start--><div id="bid">'); | |
txt = txt[2]; | |
txt = txt.split('</div><!--end-->'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Итак, за основу я взял метод ResizeImageGet. Почему? Потому что именно он делает копию картинки, а не воздействует на оригинал. И именно он внутри себя обращается к методу CFile::ResizeImageFile, который уже может наложить водяной знак. | |
Для начала создаем класс с одним статическим методом: | |
class CFileWater extends CAllFile | |
{ | |
public static $watermark = array( | |
'position' => 'mc',//допустимые http://prntscr.com/c3hc9i | |
'type' => 'file', | |
'size' => 'real', | |
'alpha_level' => 100,//прозрачность |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var script, | |
scripts = document.getElementsByTagName('script')[0]; | |
function load(url) { | |
script = document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
scripts.parentNode.insertBefore(script, scripts); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt"); | |
//define('siteType', 'dev'); | |
//Определяем мобильные устройства библиотекой http://mobiledetect.net/ | |
require_once 'include/Mobile_Detect.php'; | |
$detect = new Mobile_Detect; | |
//Все мобилные устройства кроме планшетов | |
if( $detect->isMobile() && !$detect->isTablet() ){ |