Advertisement
vanchelo

Untitled

Oct 15th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. // Формируем ID производителей для выборки
  2. if (!empty($_GET['brand'])) {
  3.     $tmp = explode(',', preg_replace('([^0-9,])', '', $_GET['brand']));
  4.     $brands = array();
  5.     foreach ($tmp as $v) {
  6.         if ( intval($v) != 0 ) $brands[] = (int) $v;
  7.     }
  8.     $this_id = $modx->resource->get('id');
  9.     $childs = $modx->getChildIds($this_id,1,array('context' => 'web'));
  10.     $brandsArr = array();
  11.     foreach ($brands as $brand) {
  12.         if(in_array($brand, $childs)) $brandsArr[] = $brand;
  13.     }
  14.     $parents = count($brandsArr) > 0 ? implode(',',array_unique($brandsArr)) : '';
  15. }
  16.  
  17. // Дальше переменную $parents я засовываю в $output = $modx-runSnippet('getResources',array('parents' => $parents))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement