39a40,68 > > // should these be variables? > $columns = 3; > $rows = 5; > > // find out which terms are being passed in > $tids = array(arg(2)); > > foreach ($tids as $index => $tid) { > $term = taxonomy_get_term($tid); > $tree = taxonomy_get_tree($term->vid, $tid, -1, $depth); > $descendant_tids[] = array_merge(array($tid), array_map('_taxonomy_get_tid_from_term', $tree)); > } > $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids)); > > $query = 'SELECT DISTINCT(n.nid) FROM {node} n '; > $query .= 'INNER JOIN {ec_product} p ON n.nid = p.nid '; > > // if tids are coming in, do this sql > if ($str_tids) { > $query .= 'INNER JOIN {term_node} tn ON n.nid = tn.nid '; > $query .= 'WHERE tn.tid IN (' . $str_tids . ') AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'; > } > else { > $query .= 'WHERE n.status = 1 ORDER BY n.sticky DESC, n.created DESC'; > } > > //fetch the products > $result = pager_query(db_rewrite_sql($query), $rows * $columns, 0); 41,44d69 < $columns = 3; < $rows = 5; < < $result = pager_query(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {ec_product} p ON n.nid = p.nid WHERE n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), $rows * $columns, 0);