Роман Ильин · 12 сентября 2017, 23:09 Сниппет для удаления старых версий: <?php /** * versionCleanX * * @author Scott Pronych, September 27, 2013 * * DESCRIPTION * * For use with VersionX to delete old content * * PROPERTIES: * * &contentType - can be resource, chunk, plugin, snippet, template, or templatevar * &maxVersions - integer value for max number of versions you would like to keep * * USAGE: * * [[!versionCleanX? &contentType=`resource` &maxVersions=`10`]] * */ $cx_type = $modx->getOption('contentType', $scriptProperties, 'resource'); $cx_max = (int) $modx->getOption('maxVersions', $scriptProperties, 5); $GLOBALS['count'] = 1; $GLOBALS['total'] = 0; $GLOBALS['deleted'] = 0; $GLOBALS['page_total'] = 0; $GLOBALS['page_deleted'] = 0; $GLOBALS['page_name'] = ''; $GLOBALS['prev_content_id'] = 0; $GLOBALS['prev_version_id'] = 0; switch ($cx_type) { case 'chunk': $name = 'name'; break; case 'plugin': $name = 'name'; break; case 'snippet': $name = 'name'; break; case 'template': $name = 'templatename'; break; case 'templatevar': $name = 'name'; break; default: $name = 'title'; $cx_type = 'resource'; } $GLOBALS['db_name'] = 'modx_versionx_' . $cx_type; function delete_row ($id) { global $modx; $query = "DELETE FROM `" . $GLOBALS['db_name'] . "` WHERE version_id = '" . $id . "'"; $result = $modx->query($query); if (!is_object($result)) return false; else { $GLOBALS['deleted']++; $GLOBALS['page_deleted']++; $GLOBALS['page_total']++; $GLOBALS['total']++; $GLOBALS['count']++; return true; } } function log_row () { $GLOBALS['data'] .= '<tr><td>' . $GLOBALS['page_name'] . '</td><td>' . $GLOBALS['page_total'] . '</td><td>' . $GLOBALS['page_deleted'] . "</td></tr>\n"; $GLOBALS['page_deleted'] = 0; $GLOBALS['page_total'] = 1; $GLOBALS['count'] = 1; } $query = "SELECT version_id, content_id, " . $name . " AS page_title FROM `" . $GLOBALS['db_name'] . "` ORDER BY content_id ASC, version_id DESC"; $GLOBALS['data'] = ''; $output = 'An error occurred: '; $versionx = $modx->query($query); if (!is_object($versionx)) { return $output . 'query error ' . print_r($modx->errorInfo(), true); } else { while($row = $versionx->fetch(PDO::FETCH_ASSOC)) { // New content_id so reset if ($prev_content_id == 0) { $prev_content_id = $row['content_id']; $prev_version_id = $row['version_id']; $GLOBALS['total']++; $GLOBALS['page_total']++; $GLOBALS['count']++; $GLOBALS['page_name'] = $row['page_title']; } elseif ($prev_content_id != $row['content_id']) { if ($GLOBALS['count'] > $cx_max) { if (!delete_row($prev_version_id)) return $output . 'deleting row for ' . $GLOBALS['page_name'] . ' Row: ' . $prev_content_id . ' ' . print_r($modx->errorInfo(), true); $GLOBALS['page_total']--; } else { $GLOBALS['total']++; $GLOBALS['count']++; } log_row(); $prev_content_id = $row['content_id']; $prev_version_id = $row['version_id']; $GLOBALS['page_name'] = $row['page_title']; } // Content count is over the max so delete previous row elseif ($GLOBALS['count'] > $cx_max) { delete_row($prev_version_id); $prev_content_id = $row['content_id']; $prev_version_id = $row['version_id']; } else { $GLOBALS['count']++; $GLOBALS['page_total']++; $GLOBALS['total']++; $prev_content_id = $row['content_id']; $prev_version_id = $row['version_id']; } } log_row(); if ($GLOBALS['data'] != '') { $output = '<h3>VersionX Cleanup for ' . $GLOBALS['db_name'] . '</h3> <p>Total records: <strong>' . $GLOBALS['total'] . '</strong> Total deleted: <strong>' . $GLOBALS['deleted'] . '</strong></p> <table class="table table-striped"> <thead> <tr> <th>Page name</th> <th>Total found</th> <th>Deleted</th> </tr> </thead> <tbody> ' . $GLOBALS['data'] . '</tbody></table> '; } else $output = 'Error: no data found.'; } $query = "OPTIMIZE TABLE `" . $GLOBALS['db_name'] . "`"; $versionx = $modx->query($query); if (!is_object($versionx)) { $output = 'Optimize error ' . print_r($modx->errorInfo(), true) . $output; } return $output; Вызывать так: [[!versionCleanX? &contentType=`resource` &maxVersions=`10`]] Вопросы / VersionX переполнил базу данных 8 +2 13
Алексей · 08 декабря 2016, 15:24 Спасибо всем за ответы и советы. Вот нашел… Сниппет выбирает и выводит все категории, к которым принадлежит товар — его можно использовать как своеобразные теги. Предложил Виктор Долгий. <?php if (empty($rid)) {$rid = $modx->resource->id;} if (empty($pid)) {$pid = $modx->resource->parent;} if (empty($delimeter)) {$delimeter = ', ';} $scheme = $modx->getOption('link_tag_scheme', null, 'full', true); $q = $modx->newQuery('msCategory'); $q->leftJoin('msCategoryMember', 'msCategoryMember', array( '`msCategory`.`id` = `msCategoryMember`.`category_id`' )); $q->sortby('pagetitle','ASC'); $q->groupby('id'); $q->select(array('id','pagetitle')); $q->where('`msCategoryMember`.`product_id` = '.$rid.' OR `id` = '.$pid); $result = array(); if ($q->prepare() && $q->stmt->execute()) { while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) { $url = $modx->makeUrl($row['id'], '', '', $scheme); $result[] = '<a href="'.$url.'">'.$row['pagetitle'].'</a>'; } } return implode($delimeter, $result);Все ссылки ведут на bezumkin.ru/modx/minishop2/solutions/1160/ — эту не действующую но актуальную страницу… по поиску ни как не нашел… и до сих пор не знаю как её найти… текст выдрал из кэша поисковиков Вопросы / Вывести список категорий к которым относится товар 2 0 3
Василий Наумкин · 20 декабря 2013, 20:51 $id = $modx->resource->id; $tpl = '@INLINE <a href="[[~[[+id]]]]">[[+pagetitle]]</a>'; $pdo = $modx->getService('pdoFetch'); $options = array( 'innerJoin' => array( 'msCategory' => array('on' => 'msCategoryMember.category_id = msCategory.id') ), 'select' => array('msCategory' => 'all'), 'sortby' => 'msCategory.id' ); $conditions = array('product_id' => $id); $rows = $pdo->getCollection('msCategoryMember', $conditions, $options); $output = ''; foreach ($rows as $row) { $output .= $pdo->getChunk($tpl, $row); } return $output; Вопросы / Вывод категорий товара тегами 20 0 2
Localizator3 для MODX 3: перевод полей и TV без отдельного context на язык, Vue 3 + PrimeV... Вложенный migx тоже переведет??
PageBuilder — визуальный конструктор страниц для MODX 3 Класс! Пара моментов смутила: 1. Почему бы чанки сразу не вынести в файлы? 2. На фронте грузится свой CSS для стандартных блоков<link rel="stylesheet" href="/a...
mxDadata — интеграция DaData (Suggest, Clean, Party) с MODX 3 и MiniShop3 Вышла новая версия: [1.0.2-pl] — 2026-10-06 Fixed #9 Права mxdadata_edit, mxdadata_logs, mxdadata_cache_clear теперь проверяются в connector.php и в Processors\Mgr\Pr...
msp3PaymentSkeleton — шаблон для создания платёжных дополнений MiniShop3 вот круто. я как то писал платежное дополнение и парился как что. а теперь надеюсь все проше будет :-)
MiniShop3 1.2.0 - 1.3.0 Самое интересное Пообщались с клиентом он сказал что тыкал в позицию т.к. она не добавлялась (видимо лагал инет) и вот она размножилась таким образом.
Modx Revo 2.8.8 + Minishop 2 (4.4.2) + Babel 3.5.2 - превью товаров в админке у дополнител... Сначала сравните ответ connector для исходного товара и его перевода во вкладке Network. Если у перевода поле миниатюры пустое, смена чанка или рендерера сама картинку не добавит: ...
Сайт тормозит сервер, грузит процессор на 100% полезно посмотреть, какие URL запрашивают эти боты и сколько времени занимает их обработка. Частые обращения к поиску и фильтрам могут нагружать PHP сильнее, чем обычные страницы. ...
Подскажите насколько это рабочее решение Спасибо за ответ. У меня время создания заказа равно времени оплаты. Заказ оплачивается сразу через iframe на сайте. При нажатии на кнопку «оформить заказ» всплывает окошко робокас...
Не всегда срабатывает JS-событие Здесь лучше разделить «заказ создан» и «заказ оплачен». Первое событие фиксируется при успешном создании заказа, второе — после проверенного уведомления платёжной системы на сервер...
Вызывать так:
Вот нашел…
Сниппет выбирает и выводит все категории, к которым принадлежит товар — его можно использовать как своеобразные теги. Предложил Виктор Долгий.
Все ссылки ведут на bezumkin.ru/modx/minishop2/solutions/1160/ — эту не действующую но актуальную страницу… по поиску ни как не нашел… и до сих пор не знаю как её найти… текст выдрал из кэша поисковиков