Пропустить теорию и перейти прямо к задачам
Ссылка на учебник: http://learn.javascript.ru
Сразу расскажу про несколько особенностей яваскрипта, о которых может быть не написано (или мало написано) в учебниках, но которые стоит понимать:
| <?php | |
| $q = $modx->newQuery('modResource', array( | |
| 'parent:IN' => array(0), // Перечисляем id разделов, если надо, но если документов не очень много, то можно с корня | |
| )); | |
| // Это условие указывает поиск только документов без uri | |
| $q->andCondition(array( | |
| 'uri' => null, | |
| 'OR:uri:=' => '', | |
| )); |
| //плагин на событие 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; |
| <?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() { | |
| <?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.'); |
| <script> | |
| miniShop2.Order.deliveryCost = '#ms2_delivery_cost'; | |
| miniShop2.Callbacks.Order.getcost.response.success = function(response) { | |
| var rdc = response.data['delivery_cost']; | |
| if(rdc) $(miniShop2.Order.deliveryCost, miniShop2.Order.order).text(miniShop2.Utils.formatPrice(rdc)); | |
| else $(miniShop2.Order.deliveryCost, miniShop2.Order.order).text('0'); | |
| } |
| &where=`{ "template:IN" : [ 1,2,3 ] } | |
| &where=`{ "template:NOT IN" : [ 1,2,3 ] } | |
| &where=`[{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}]` |
| /* | |
| * Replace all SVG images with inline SVG | |
| */ | |
| jQuery('img.svg').each(function(){ | |
| var $img = jQuery(this); | |
| var imgID = $img.attr('id'); | |
| var imgClass = $img.attr('class'); | |
| var imgURL = $img.attr('src'); | |
| jQuery.get(imgURL, function(data) { |
| /** | |
| * Custom Bootstrap 3 grid for 480-767px layout | |
| * Author: Iftakhar Hasan | |
| * | |
| * A new set of column classes (with class prefix .col-ms- ) for Bootstrap 3 | |
| * to make Medium Small grids for supporting 480-767px | |
| * | |
| * This will push the default Bootstrap 3 Extra Small column (class prefix .col-xs- ) | |
| * to support 1-479px instead of 1-767px | |
| */ |
| <?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) { |
Пропустить теорию и перейти прямо к задачам
Ссылка на учебник: http://learn.javascript.ru
Сразу расскажу про несколько особенностей яваскрипта, о которых может быть не написано (или мало написано) в учебниках, но которые стоит понимать: