Skip to content

Instantly share code, notes, and snippets.

View alexsoin's full-sized avatar

Alex Soin alexsoin

View GitHub Profile
@alexsoin
alexsoin / updateMODXresource.php
Created February 26, 2018 07:54
Обновление ресурса в modx revo
<?php
if($doc = $modx->getObject('modResource', $ResId)){
$data = $doc->toArray();
$data['content'] = $content;
$response = $modx->runProcessor('resource/update', $data);
$modx->cacheManager->clearCache();
}
@alexsoin
alexsoin / nginx.conf
Created February 26, 2018 05:13
nginx proxy_cache
http {
# ...
# Указываем папку для хранения кэша и ограничиваем его размер
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:30m max_size=1g;
# Кэширующий хост
server {
listen 80;
@alexsoin
alexsoin / createMSProducts.php
Created February 22, 2018 08:46
создание товара miniShop2 через процессор
<?php
$response = $modx->runProcessor('resource/create', array(
'class_key' => 'msProduct',
'pagetitle' => 'Товар',
'parent' => 55,
'template' => 11,
'show_in_tree' => 1,
//Данные
'price' => 100,
@alexsoin
alexsoin / updateTV.php
Created February 22, 2018 08:44
Устанавливаем ТВ параметру mytv значение new у ресурса с id = 15
<?php
// Устанавливаем ТВ параметру mytv значение new у ресурса с id = 15
if ($resource = $modx->getObject('modResource', 15)) {
$resource->setTVValue('mytv', 'new');
}
@alexsoin
alexsoin / shadow_bg.css
Created December 12, 2017 07:32
Добавление затемнения на background
.bg {
background-image: url('img/img.jpg');
background-repeat: no-repeat;
background-position: top center;
background-size: cover;
height: 100vh;
width: 100%;
position: relative;
-webkit-transition: all 0.4s;
-moz-transition: all 0.4s;
@alexsoin
alexsoin / fenomGetMigx.tpl
Last active April 27, 2018 06:28
Вывод содержимого MIGX полей с помощью Fenom
{var $rows = ID | resource : 'elements' | fromJSON}
{foreach $rows as $idx => $row}
{$row.image}
{/foreach}
@alexsoin
alexsoin / updatePhotoMSGallery.php
Created May 12, 2017 09:44
Обновление фото товаров после переустановки минишоп (подходит для ms2Gallery но можно переделать под miniShop, запускать через SSH)
<?php
//set_time_limit(00);
define('MODX_API_MODE', true);
require 'index.php';
$basePath = getcwd();
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget(array
(
@alexsoin
alexsoin / googleview.php
Last active April 28, 2017 09:32
Просмотр на сайте doc файлов
<?
if ($_GET['url'] != ""){?>
<iframe src="http://docs.google.com/gview?url=http://site.ru<?=$_GET['url']?>
&amp;embedded=true" width="100%" height="98%" frameborder="0">Ваш браузер не поддерживает фреймы
</iframe><?
} else {
}?>
@alexsoin
alexsoin / update_id.js
Created April 7, 2017 06:24
Обновление блока без перезагрузки страницы
$('#id').load(location.href+' #id>*','');
@alexsoin
alexsoin / NoIntrotextModx.php
Last active April 5, 2017 07:50
Запретить Tickets заполнять introtext. Плагин на событие OnDocFormSave
<?php
if ($modx->event->name == "OnDocFormSave") {
if ($resource->class_key != 'Ticket') return;
$introtext = $resource->get('introtext');
$generateIntrotext = $resource->getIntroText($resource->get('content'), false);
if (empty($resource->getProperty('disable_jevix'))) {
$generateIntrotext = $resource->Jevix($generateIntrotext);
}
if ($introtext == $generateIntrotext) {
$resource->set('introtext', '');