欢迎各位兄弟 发布技术文章
这里的技术是共享的
function _shipingzhongcustomten_get_view_total($view_name,$display_id) { global $user; $view = views_get_view($view_name); $view->set_display($display_id); $view -> get_total_rows = TRUE ; $endTime = date('Y-m-d',(time()-15*24*60*60)); //这里对于结束时间进行的处理 $item=array(); $item = $view->get_item($display_id, 'filter', 'field_shangmeng_time_value_1'); $item['value'] = array('value'=>$endTime,'default_date'=>$endTime); $item['default_date'] = $endTime; //最好加上这一句 $view->set_item($display_id, 'filter', 'field_shangmeng_time_value_1', $item); if (in_array('仅查看吴中爱丁堡的上门未报名',$user->roles) ) { $item=array(); $item = $view->get_item($display_id, 'filter', 'field_suozaixiaoqu_value_many_to_one'); $item['exposed'] = false; $item['expose']['single'] = 0; $item['value'] = array( 'xq'=>'xq', 'wz'=>'wz' ); $view->set_item($display_id, 'filter', 'field_suozaixiaoqu_value_many_to_one', $item); } if (in_array('仅查看华东的上门未报名',$user->roles) ) { $item=array(); $item = $view->get_item($display_id, 'filter', 'field_suozaixiaoqu_value_many_to_one'); $item['exposed'] = false; $item['expose']['single'] = 1; $item['value'] = array( 'hd'=>'hd' ); $view->set_item($display_id, 'filter', 'field_suozaixiaoqu_value_many_to_one', $item); } $view->pre_execute(); $view ->execute() ; $page_total = count($view->result); if(isset($view->total_rows)){ return $view->total_rows ; } else { return $page_total ; } }