function get_current_view_results_as_csv($position_only = false, $nid = 0) { $view = views_get_current_view(); $result_nids = array(); foreach($view->result as $row_id => $row){ $result_nids[] = $row->nid; } if($position_only){ return array_search($nid, $result_nids); }else{ return implode(',', $result_nids); } }
The above function will give you the result node ids in the current view as a CSV list. If $position_only = TRUE then you need to pass the nid and the functiton will return the position of the given nodeid in the current view results.
No comments:
Post a Comment