Skip to content

Instantly share code, notes, and snippets.

@Tabys
Tabys / output of resources with a separator
Created April 17, 2020 03:05
Вывод ресурсов с разделением по категориям
<?php
$letters = $modx->runSnippet('tvssCloud', array(
'parents' => $modx->resource->get('id'),
'tv'=> '69',
'tpl' => '@INLINE {$tag}',
'tplWrapper' => '@INLINE {$output}'
));
$arr = explode('||', $letters);
$uarr = array_unique($arr);
@Tabys
Tabys / plagin to msOptionsPrice2
Created April 17, 2020 02:43
Для подстановки артикулов(модификаций) в поле introtext (для поиска товара по артикулу)
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnDocFormSave':
$modpar = array(
'rid' => $id
);
$mod = $modx->getCollection('msopModification', $modpar);
@Tabys
Tabys / plagin to mspReceiptAccount
Created April 17, 2020 02:41
Плагин для mspReceiptAccount (добавляет кастомные поля из формы сразу в Счет) в шаблоне с Счетом вызывается так - {$order.properties.mspra.inn_custom}
<?php
switch($modx->event->name) {
case 'msOnBeforeCreateOrder':
$data = $order->get();
$properties['mspra'] = array(
'inn_custom' => $data['inn_custom'],
'kpp_custom' => $data['kpp_custom'],
'yraddress' => $data['yraddress_custom'],
);
$msOrder->set('properties', $properties);
@Tabys
Tabys / import CSV to mySql
Last active April 17, 2020 02:37
Простеньки импорт из csv
#!/usr/bin/php
<?php
$options = array(
'filename' => '/home/.../site.ru/import.csv',
'db_server' => 'localhost', // Сервер БД
'db_user' => 'acberebx_auto', // Имя пользователя
'db_password' => 'jt%n9%nG', // Пароль
'db_base' => 'acberebx_auto' // Имя базы данных
);
@Tabys
Tabys / msieReplacementSeparator
Created June 23, 2019 17:44
Разные разделители для msImportExport (на событие msieOnBeforePrepareImportProduct)
<?php
/** @var modX $modx */
// Массив ID настроек полей для которых нужно использовать данный плагин http://prntscr.com/kkwx4r
$presets = array(2);
$subDelimeter = $modx->getOption('msimportexport.import.sub_delimeter', null, '|');
if (!empty($presets) && !in_array($preset, $presets)) return;
switch ($modx->event->name) {
case 'msieOnBeforePrepareImportProduct':
$keys = array_flip($fields);
@Tabys
Tabys / Scroll
Created May 11, 2019 17:43
Плавный скрол
$('.about_job .form-open').on('click', function() {
$('.about_job .forma').show();
var el = $(this).attr('href');
el = el.replace(/[^\#]*/, '');
$('body,html').animate({
scrollTop: $(el).offset().top - 100}, 1000);
return false;
});
@Tabys
Tabys / Parser cURL + simple_html_dom
Created November 16, 2018 10:03
[[get-news? &url=`[[+url-news]]` &elem=`[[+element]]` &baseurl=`[[+base-url]]` &iter=`[[+iter]]`]]
<?php
require_once 'simple_html_dom.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, "$url");
curl_setopt($curl, CURLOPT_REFERER, "$url");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201');
@Tabys
Tabys / htaccess
Created June 26, 2018 18:47
Запись для корректного URL в других контекстах на картинки
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|ru)/assets(.*)$ assets$2 [L,QSA]
@Tabys
Tabys / Tabs
Created February 9, 2018 11:26
Табы для сайта
<div class="tabs">
<ul class="tabs__caption">
<li class="active"></li>
<li></li>
</ul>
<div class="tabs__content active">
</div>
<div class="tabs__content">
</div>
</div>
@Tabys
Tabys / Copyright
Created October 1, 2017 14:41
Выводит текущую дату