Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Sentinel-7 / level.php
Created August 5, 2020 10:26
Получаем уровень вложенности
<?php
$parentPageId = $modx->resource->get('id');
$level = count($modx->getParentIds($parentPageId));
echo $level;
@Sentinel-7
Sentinel-7 / plugin.php
Created August 4, 2020 10:34 — forked from ig0r74/plugin.php
MODX убрать все type="text/javascript"
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$output = &$modx->resource->_output; // перехватываем содержимое страницы
$output = str_replace(' type="text/javascript"',"",$output);
break;
}
@Sentinel-7
Sentinel-7 / mfilter2_more_button.js
Last active August 4, 2020 10:31 — forked from ig0r74/mfilter2_more_button.js
MODX mFilter2 одновременное использование стандартной пагинации и подгрузки кнопкой
$('.btn_more_custom').click(function() {
var href = $('.mse2_pagination .page-item.active').next('.page-item').find('.page-link').attr('href');
if (typeof href !== "undefined") {
mSearch2.addPage();
}
});
$(document).on('mse2_load', function(e, data) {
if (typeof $('.mse2_pagination .page-item.active').next('.page-item').next('.page-item').find('.page-link').attr('href') === "undefined") {
$('.btn_more_custom').hide();
@Sentinel-7
Sentinel-7 / LoadLexicon.php
Created August 4, 2020 10:30 — forked from ig0r74/LoadLexicon.php
Localizator подгрузка лексиконов для mFilter2
<?php
$eventName = $modx->event->name;
switch($eventName) {
// case 'OnWebPageInit':
// if ($modx->context->get('key') == 'mgr') {return;}
// $modx->lexicon->load($modx->cultureKey . ':minishop2:default');
// break;
case 'OnParseDocument':
if ($modx->context->get('key') == 'mgr') {return;}
@Sentinel-7
Sentinel-7 / client_config
Created July 25, 2020 15:50 — forked from qwertik17/client_config
Add groups & fields for MODx ClientConfig
<?php
//СОЗДАНИЕ ИЛИ ОБНОВЛЕНИЕ ГРУПП
$groups = array(
array('id' => 1,'sortorder' => 1,'label' => 'Общие'),
array('id' => 2,'sortorder' => 2,'label' => 'Почта'),
array('id' => 3,'sortorder' => 3,'label' => 'Политика и куки'),
array('id' => 4,'sortorder' => 4,'label' => 'Социальные сети'),
);
foreach ($groups as $group)
@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);
@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 / 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 / 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 / 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(){