In this example i would add a join to the database table “node” with an other database table “event_submissions” which i created in my custom module, so i will add a hook_views_query_alter() function in mymodule.module file :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if($view->name === 'event_calendar' && $view->current_display === 'event_month_calendar'){ global $user; $join_def['table'] = 'event_submissions'; $join_def['field'] = 'nid'; $join_def['left_table'] = 'node'; $join_def['left_field'] = 'nid'; $join_def['extra'] = 'es.uid = ' . $user->uid . ' AND es.canceled = 0'; $join = new views_join(); $join->definition = $join_def; $join->construct(); $join->adjusted = TRUE; $view->query->add_relationship('es', $join); $query->add_where(0, 'es.uid', '', 'IS NOT NULL'); } |
This code allows me to get the events that the current user had participated.
No comments yet.