Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Sentinel-7 / client_config
Created July 25, 2020 15:50 — forked from qwertik17/client_config
Add groups & fields for MODx ClientConfig
<?php
//СОЗДАНИЕ ИЛИ ОБНОВЛЕНИЕ ГРУПП
$groups = array(
array('id' => 1,'sortorder' => 1,'label' => 'Общие'),
array('id' => 2,'sortorder' => 2,'label' => 'Почта'),
array('id' => 3,'sortorder' => 3,'label' => 'Политика и куки'),
array('id' => 4,'sortorder' => 4,'label' => 'Социальные сети'),
);
foreach ($groups as $group)
@Sentinel-7
Sentinel-7 / LoadLexicon.php
Created August 4, 2020 10:30 — forked from ig0r74/LoadLexicon.php
Localizator подгрузка лексиконов для mFilter2
<?php
$eventName = $modx->event->name;
switch($eventName) {
// case 'OnWebPageInit':
// if ($modx->context->get('key') == 'mgr') {return;}
// $modx->lexicon->load($modx->cultureKey . ':minishop2:default');
// break;
case 'OnParseDocument':
if ($modx->context->get('key') == 'mgr') {return;}
@Sentinel-7
Sentinel-7 / mfilter2_more_button.js
Last active August 4, 2020 10:31 — forked from ig0r74/mfilter2_more_button.js
MODX mFilter2 одновременное использование стандартной пагинации и подгрузки кнопкой
$('.btn_more_custom').click(function() {
var href = $('.mse2_pagination .page-item.active').next('.page-item').find('.page-link').attr('href');
if (typeof href !== "undefined") {
mSearch2.addPage();
}
});
$(document).on('mse2_load', function(e, data) {
if (typeof $('.mse2_pagination .page-item.active').next('.page-item').next('.page-item').find('.page-link').attr('href') === "undefined") {
$('.btn_more_custom').hide();
@Sentinel-7
Sentinel-7 / plugin.php
Created August 4, 2020 10:34 — forked from ig0r74/plugin.php
MODX убрать все type="text/javascript"
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$output = &$modx->resource->_output; // перехватываем содержимое страницы
$output = str_replace(' type="text/javascript"',"",$output);
break;
}
@Sentinel-7
Sentinel-7 / level.php
Created August 5, 2020 10:26
Получаем уровень вложенности
<?php
$parentPageId = $modx->resource->get('id');
$level = count($modx->getParentIds($parentPageId));
echo $level;
@Sentinel-7
Sentinel-7 / chunk.tpl
Created September 21, 2020 15:27
AjaxForm цели
<button type="submit" onclick="ga('send', 'zakazat_zvonok', '/'); ym(99999,'reachGoal','ostavit_zayavku'); return true;" class="bt_red" style="display: block;">
$(document).on("af_complete", function (event, response) {
var fid = response.form[0].id;
switch (fid) {
case 'question':
case 'online':
case 'modal_form':
case 'regForm':
@Sentinel-7
Sentinel-7 / taggercustomfilter.class.php
Created December 16, 2020 19:33 — forked from sheronov/taggercustomfilter.class.php
Интеграция компонента Tagger с фильтрами в mFilter2 (компонент mSearch2) - Расширение класса фильтрации через системную настройку mse2_filters_handler_class
<?php
class taggerCustomFilter extends mse2FiltersHandler {
/**
* Retrieves values from Tagger table
*
* @param array $fields
* @param array $ids
*
* @return array
@Sentinel-7
Sentinel-7 / getViewed.php
Last active December 29, 2020 16:51 — forked from shvind/gist:8273223
getViewed - Сниппет вывода просмотренных товаров для minishop2
<?php
$id = $modx->resource->id;
$tpls = explode(',', $modx->getOption('ms2_template_product_default'));
if (!isset($limit)) {$limit = 10;}
if (!isset($tpl)) {$tpl = 'tpl.msProducts.row';}
// Вносим ID просмотренных товаров
if (in_array($modx->resource->template, $tpls)) {
if (!isset($_SESSION['viewed'])) {
@Sentinel-7
Sentinel-7 / settimeout.js
Last active November 19, 2022 12:51
Отложенная загрузка метрики и скриптов
var loadedMetrica = false;
window.addEventListener('scroll', loadMetrica);
window.addEventListener('click', loadMetrica);
window.addEventListener('mousemove', loadMetrica);
function loadMetrica() {
if (!loadedMetrica) {
setTimeout(function() {
/* ТУТ ВАШ КОД И СКРИПТЫ, метрика например*/
},500);
}
@Sentinel-7
Sentinel-7 / createUser.php
Created February 12, 2021 15:48 — forked from andronex/createUser.php
Создание юзера и добавление его в группу (hook для FormIt MODX Revolution) - 2 способа + отдельным файлом с запросом Ajax
<?php
$allFormFields = $hook->getValues();
if(is_array($allFormFields)){
foreach($allFormFields as $k => $v){
if (filter_var($v, FILTER_VALIDATE_EMAIL)) {
$mail = trim($v);
}
}
if($mail){