This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rand = rand(1, 1000); | |
if ($rand === 1) { | |
$gcMaxlifetime = (integer) $modx->getOption('session_gc_maxlifetime', null, @ini_get('session.gc_maxlifetime'), true); | |
$access = time() - $gcMaxlifetime; | |
$modx->exec(" | |
DELETE FROM {$modx->getTableName('modSession')} WHERE `access` < {$access}; | |
OPTIMIZE TABLE {$modx->getTableName('modSession')}; | |
"); | |
$modx->log(modX::LOG_LEVEL_ERROR, 'clearOldSessions: old sessions have been removed.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$eventName = $modx->event->name; | |
switch($eventName) { | |
case 'OnDocFormPrerender': | |
// Для ресурсов с индетификатором шаблона 2 | |
// а также для всех новых ресурсов ( $resource == null ) | |
if( $resource && $resource->get('template') == 2 || !$resource){ | |
$modx->regClientStartupHTMLBlock('<script> | |
Ext.onReady(function() { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//плагин на событие msOnBeforeAddToCart. | |
$cartArray = $cart->get(); // Массив корзины | |
$cartStatus = $cart->status(); // Состояние корзины | |
$totalCount = $cartStatus['total_count']; // Общее количество товаров в корзине | |
foreach ($cartArray as &$cartProduct) { // Обрабатываем все товары корзины | |
if ($product = $modx->getObject('msProduct', $cartProduct['id'])) { // Получаем объект товара по его ID в корзине | |
$quanity = $product->get('count_prod)'; | |
$cartQuantity = $cartProduct["count"]; | |
if($cartQuantity > $quanity){ | |
$cartProduct['count'] = $quanity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$q = $modx->newQuery('modResource', array( | |
'parent:IN' => array(0), // Перечисляем id разделов, если надо, но если документов не очень много, то можно с корня | |
)); | |
// Это условие указывает поиск только документов без uri | |
$q->andCondition(array( | |
'uri' => null, | |
'OR:uri:=' => '', | |
)); |
OlderNewer