如果你想在动态修改你的view的查询条件,还是在modulename.views.inc 文件下创建modulename_views_query_alter(&$view,
&$query) 这个函数中进行动态的修改,code如下:
$joinObj = new views_join; 如果想详细了解这个 views_join类 查看handlers.inc 文件1465行, $joinObj ->construct('field_data_field_name', 'node', 'nid', 'entity_id'); //表 field_data_field_name a 关联 表 node b on b.nid = a.entity_id $query->add_relationship('field_data_field_name', $joinObj , 'node'); $query->where[1]['conditions'][$num]['field'] = 'field_data_field_name.field_name_value'; $query->where[1]['conditions'][$num]['value'] = $queryvalue; $query->where[1]['conditions'][$num]['operator'] = ([=] [!=] [in]) eg;
详细可参考文章:
点击打开链接