Skip to content

Instantly share code, notes, and snippets.

View 0test's full-sized avatar

Andrey 0test

View GitHub Profile
@0test
0test / categoryUpdate
Last active April 23, 2020 20:12
При сохранении и перемещении товаров обновляет их категорию, для использования в фильтрах
/**
* categoryUpdate
*
* При сохранении и перемещении товаров обновляет их категорию, для использования в фильтрах
*
* @category plugins
* @internal @events onAfterMoveDocument,OnDocFormSave
*/
$e = $modx->Event;
@0test
0test / ajax.php
Last active November 27, 2019 20:16
AJAX file Evolution CMS
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)){
$modx->getSettings();
}
$modx->invokeEvent("OnWebPageInit");
@0test
0test / ajax.js
Last active November 14, 2019 12:01
Мой любимый аякс - обёртка для вызова
var ajax = {
post: function(form_wrapper_id,form_id,query_key,success_callback){
//обёртка формы, айди формы, ключ запроса, код на успех
$.ajax({
type: 'post',
url: '/ajax.php?q=' + query_key,
data: $(form_id).serialize(),
success:success_callback
});
}
@0test
0test / gist:2c897070bb07cab08b50c2aafe6631b8
Created August 28, 2019 09:24
Prepare editDocs and set multitv values
<?php
$process = isset($process) ? $process : '';
$mode = isset($mode) ? $mode : '';
switch ($process) {
case 'import':
//обработчик импорта
switch ($mode) {
case 'upd':
//обновляем ресурс
$data['img'] = 'assets/images/products/' . $data['art'] . '/' . $data['art'] . '.jpg';
@0test
0test / ChangeManagerThree
Created August 29, 2019 19:04
Изменяем некоторые иконки в дереве
$e = &$modx->Event;
if($e->name = 'OnManagerNodePrerender'){
/* Разделы каталога */
if($ph['template'] == '6'){
$ph['icon'] = "<i class='fa fa-table'></i>";
$ph['icon_folder_open'] = "<i class='fa fa-table'></i>";
$ph['icon_folder_close'] = "<i class='fa fa-table'></i>";
$ph['contextmenu'] = array(
'header1' => array(
@0test
0test / ajax.php
Last active November 14, 2019 11:59
Поиск и быстрая покупка аякс
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)){
$modx->getSettings();
}
$modx->invokeEvent("OnWebPageInit");
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')){
$modx->sendRedirect($modx->config['site_url']);
@0test
0test / market.yml
Last active December 23, 2020 12:13
market.yml for Yandex
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="[!mDate? &date=`[*editedon*]`!]">
<shop>
<name>[(site_name)]</name>
<company>[(site_name)]</company>
<url>[(site_url)]</url>
<currencies>
<currency id="RUR" rate="1"/>
</currencies>
@0test
0test / order_body_tpl
Last active February 2, 2021 10:58
Commerce - view one order
<tr class="orders_history_one">
<td>[+position+]</td>
<td></span><a href="[~[+product_id+]~]" target="_blank">[+title+]</a></td>
<td style="text-align:center;"><span class="showmobile">Опции</span>[+options+]</td>
<td style="text-align:center;"><span class="showmobile">Количество</span>[+count+]</td>
<td style="text-align:center;"><span class="showmobile">Цена</span>[[PriceFormat? &price=`[+price+]` &convert=`1`]]</td>
<td style="text-align: right; white-space: nowrap;"><span class="showmobile">Стоимость</span>[[PriceFormat? &price=`[+total+]` &convert=`1`]]</td>
</tr>
@0test
0test / TVid.php
Last active March 10, 2021 09:28
<?php
return [
'settings' => [],
'templates' => [
'newsimage' => [
'type' => 'row',
'value' => false,
'label' => 'Фото',
'items.class' => 'd-block',
@0test
0test / TVid.php
Created March 10, 2021 09:30
tabs
<?php
return [
'settings' => [],
'templates' => [
'region_block' => [
'value' => true,
'type' => 'row',
'title' => 'Один таб',
'label' => 'Один таб',