Немного допилил сниппет Василия по выводу последних просмотренных товаров для работы со вторым минишопом. Ничего особенного, но может кому пригодиться.
Можно использовать все плюшки pdoPage и вызывать например так:
[[!getViewed? &action=`returnViewed` &tpl=`tpl.msProducts.row2` &includeThumbs=`390x300` &limit=`3` ]]
Сам сниппет добавил на github gist.github.com/shvind/8273223
<?php $id = $modx->resource->id; $tpls = explode(',', $modx->getOption('ms2_template_product_default')); if (!isset($limit)) {$limit = 10;} if (!isset($tpl)) {$tpl = 'tpl.msProducts.row';} // Вносим ID просмотренных товаров if (in_array($modx->resource->template, $tpls)) { if (!isset($_SESSION['viewed'])) { $_SESSION['viewed'] = array($id); } else { if (in_array($id, $_SESSION['viewed'])) { $key = array_search($id, $_SESSION['viewed']); unset($_SESSION['viewed'][$key]); } if (count($_SESSION['viewed']) > $limit) { array_shift($_SESSION['viewed']); } $_SESSION['viewed'][] = $id; } } // Если указано действие returnViewed - выводим просмотренные товары if ($action == 'returnViewed') { $ids = array_reverse($_SESSION['viewed']); if (empty($ids)) {return;} $config = array( 'resources' => '-'.$modx->resource->id.','.implode(',', $ids) ,'parents' => -1 ,'tpl' => $tpl ,'limit' => $limit ,'element' => 'msProducts' ,'includeContent' => 1 ); $config = array_merge($config, $scriptProperties); return $modx->runSnippet('pdoPage', $config); }
Вы должны авторизоваться, чтобы оставлять комментарии.