Skip to content

Instantly share code, notes, and snippets.

@ig0r74
ig0r74 / plugin.php
Created January 21, 2020 10:48
MODX убрать все type="text/javascript"
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$output = &$modx->resource->_output; // перехватываем содержимое страницы
$output = str_replace(' type="text/javascript"',"",$output);
break;
}
@ig0r74
ig0r74 / multiple_items.js
Last active June 14, 2021 22:10
Добавление нескольких товаров в корзину MODX miniShop2
$('button#cart_add').click(function(e){ // не забудьте изменить селектор
// Добавляем товары в корзину
var products = [];
$('input[name="price"]:checked').each(function () {
var product = {};
product['id'] = $(this).data('dop');
product['count'] = $(this).parents('.tm-dop').find('input.number-input').val();
products.push(product);
});
// Добавляем услуги в корзину
@ig0r74
ig0r74 / modx_user_auth.php
Created October 23, 2019 13:59
MODX Revolution авторизоваться под произвольным пользователем
<?php
$user = $modx->getObject('modUser', 7371);
echo $user->get('username');
$user->addSessionContext('web');
@ig0r74
ig0r74 / concat.tpl
Last active February 21, 2020 12:28
MODX Revolution, pdoResources группировка результатов leftJoin GROUP_CONCAT
{* К одному региону может принадлежать несколько магазинов *}
{set $fdkRegions = '!pdoResources' | snippet : [
'class' => 'fdkRegion',
'select' => '{
"fdkRegion":"*",
"Shop":"GROUP_CONCAT(Shop.region_id) AS region_id, Shop.main_contact_phone as main_contact_phone"
}',
'groupby' => 'code',
'leftJoin' => '{
"fdkShop": {
@ig0r74
ig0r74 / update_all_products.php
Created December 13, 2018 15:31
MODX MiniShop2 пересохранить все товары процессором
<?php
ini_set('max_execution_time', 0);
ignore_user_abort(true);
$c = 'modResource';
$q = $modx->newQuery($c);
$q->where(array('class_key' => 'msProduct'));
$q->sortby('id');
$q->select(array(
"{$c}.*",
));
@ig0r74
ig0r74 / tpl.modInstagram.item.tpl
Created November 8, 2018 13:25
modInstagram Bootstrap 4 chunk
{if ($idx - 1) % 3 == 0}
<div class="row">
{/if}
<div class="col-12 col-md-4 in-item">
<div class="card">
{switch $type}
{case 'carousel'}
<div id="carouselInstagram" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
{foreach $carousel as $item}
# /etc/monit/monitrc
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
@ig0r74
ig0r74 / rename-fields.js
Last active August 1, 2018 06:23
Скрипт меняет заголовки и прикручивает TinyMCE к описанию и интротексту в MODX
Ext.onReady(function() {
MODx.renameLabel("modx-panel-resource", ["description", "introtext"], ["Краткое описание", "Текст перед характеристиками"]);
if (MODx.loadRTE) {
MODx.loadRTE("modx-resource-description");
MODx.loadRTE("modx-resource-introtext");
}
});
@ig0r74
ig0r74 / migx_social_networks.json
Created May 30, 2018 14:15
MIGX Соцсети с иконками
{
"formtabs":[
{
"MIGX_id":8,
"caption":"",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":27,
"field":"icon",
@ig0r74
ig0r74 / banUploadToTheRoot.php
Last active May 21, 2020 19:15
Запрещаем загрузку файлов в корень сайта MODX Revolution
<?php
switch($modx->event->name){
case 'OnFileManagerUpload':
$source = & $scriptProperties['source'];
if(!$source->hasErrors()){
/*
Запрещаем загрузку в корень, точнее удаляем новый файл,