Skip to content

Instantly share code, notes, and snippets.

View alexsoin's full-sized avatar

Alex Soin alexsoin

View GitHub Profile
@alexsoin
alexsoin / modxredirect.php
Last active April 6, 2017 07:25
Плагин редиректа с http на https - modx plugin for OnHandleRequest to redirect from http to https
<?php
if ($modx->event->name != "OnHandleRequest") {return;}
$uri = $_SERVER['REQUEST_URI'];
if ($uri == '/robots.txt') return;
$url = $_SERVER['HTTP_HOST'];
$site_url = 'site.ru'; // replace with your domain
if ($url != $site_url || !$_SERVER['HTTPS']) {
$modx->sendRedirect('https://'.$site_url.$uri, array(
'responseCode' => 'HTTP/1.1 301 Moved Permanently')
@alexsoin
alexsoin / modxRemoveOldVersions.php
Last active April 5, 2017 07:49
Удаление старых версий пакетов в modx - Remove old versions of packages in modx. To run in console.
<?php
define('MODX_API_MODE', true);
require 'index.php';
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('ECHO');
if (!XPDO_CLI_MODE) {
echo '<pre>';
}
@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', '');
@alexsoin
alexsoin / update_id.js
Created April 7, 2017 06:24
Обновление блока без перезагрузки страницы
$('#id').load(location.href+' #id>*','');
@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 / 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 / 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 / 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 / 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 / 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,