Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Sentinel-7 / script.js
Last active June 1, 2024 00:47
AjaxForm закрытие окна после отправки + fancybox
<script>
$(document).ready(function() {
AjaxForm.Message.success = function() {};
});
$(document).on('af_complete', function(event,res) {
if(res.success) $('.fancybox-close-small').click();
if (res.success) {
// показываем сообщение об успехе
$.fancybox.close();
@Sentinel-7
Sentinel-7 / fenom
Last active June 1, 2024 00:47
MIGX + разбивка по 3 блока
{set $rows = 1 | resource : 'partner' | fromJSON}
<div>
<ul class="partners">
{foreach $rows as $row index=$idx}
<li><a href="{$row.url}"><img src="{$row.image}" alt=""></a>{$idx}</li>
{if ($idx+1) % 3 == 0 && count($rows) > $idx+1 }
</ul> </div> <div> <ul class="partners">
{/if}
{/foreach}
@Sentinel-7
Sentinel-7 / tpl.mFilter2.outer.html
Created July 19, 2019 13:24
tpl.mFilter2.outer
{if $_modx->getPlaceholder('mf2_total') != 0}
<div class="row msearch2" id="mse2_mfilter">
<div class="filters">
<form action="[[~[[*id]]]]" method="post" id="mse2_filters">
<div class="left">
[[+mf2_ms|vendor:vendors]]
<div class="for_hid">
@Sentinel-7
Sentinel-7 / head.tpl
Last active October 9, 2019 07:05
head
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="x-rim-auto-match" content="none">
<base href="{$_modx->config.site_url}" />
{if $_modx->resource.titl}
<title>{$_modx->resource.titl| ereplace:'/\"([^\"]*)\"/':'«$1»'}{if $city_name_conjugate} {$city_name_conjugate}{/if}</title>
{elseif $_modx->resource.template in [7]}
<title>{$_modx->resource.pagetitle| ereplace:'/\"([^\"]*)\"/':'«$1»'}{if $city_name_conjugate} - купить оптом {$city_name_conjugate}{/if}</title>
{elseif $_modx->resource.id in [4]}
@Sentinel-7
Sentinel-7 / getlist.class.php#L68
Created January 27, 2020 10:22
Сделать поиск в каталоге minishop2 по id заголовка
https://github.com/bezumkin/miniShop2/blob/master/core/components/minishop2/processors/mgr/product/getlist.class.php#L69
// начиная с 68 строки
if (!empty($query)) {
//if (is_numeric($query)) {
// $c->where(array(
// 'msProduct.id' => $query,
// 'OR:Data.article:=' => $query,
// ));
//} else {
$c->where(array(
@Sentinel-7
Sentinel-7 / gist:daf16a70dab1703513fa94c5ce5aff95
Last active August 18, 2021 14:47
Передаем title в форму
в чанке формы пишем
<div class="form-group">
<input type="text" name="product" value="[[!+fi.product]]" class="form-control" readonly="readonly">
</div>
JS вешаем на кнопку
{ignore}
<script>
$(document).ready(function() {
$('a.theme-btn.btn-style-five').on('click', function(){
@Sentinel-7
Sentinel-7 / msOrder
Created March 3, 2020 07:49 — forked from grachov/msOrder
Простой способ для пересчета стоимости заказа после его изменения
<?php
class msOrder extends xPDOSimpleObject
{
public function updateProducts()
{
$originalContext = $this->xpdo->context->get('key');
$this->xpdo->switchContext($this->get('context'));
$originalMiniShop = isset($this->xpdo->services['minishop2']) ? $this->xpdo->services['minishop2'] : null;
$cart = array();
foreach ($this->getMany('Products') as $product) {
@Sentinel-7
Sentinel-7 / config migx video
Last active December 14, 2023 20:51
migx в migx
{
"formtabs":[
{
"MIGX_id":2,
"caption":"\u0412\u043a\u043b\u0430\u0434\u043a\u0430",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":4,
"field":"tab_name",
@Sentinel-7
Sentinel-7 / diler.tpl
Last active May 8, 2020 07:39
mFilter2 google map company
в head
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maps.google.com/maps/api/js?language=ru&key=AIzaSyBkYlYr9e5MXFICXWBIxDZgg8N53X_WiSU"></script>
<script src="/assets/js/infobox.min.js"></script>
<script src="/assets/js/markerclusterer.js"></script>
=======================================================
вызов в шаблоне
{if $.get.tpl == '0' || $.get.tpl == ''}
@Sentinel-7
Sentinel-7 / OptionsCat.php
Created May 31, 2020 16:13
Собираем поля опций товара для mFilter2
<?php
$catid = array($modx->resource->id);
$in_id = implode(",", $catid) ;
$sql = "SELECT msc.category_id, msc.option_id, mso.key, mso.type
FROM {$modx->getTableName('msCategoryOption')} msc
LEFT JOIN {$modx->getTableName('msOption')} mso ON msc.option_id = mso.id
WHERE msc.category_id IN ($in_id) AND mso.filtr=1 ORDER BY mso.category, mso.id ASC";
$q = $modx->prepare($sql);
$q->execute();
$options = $q->fetchAll(PDO::FETCH_ASSOC);