I have created an ajax view that displays the contents of a group. It shows one page at a time, with a nice jquery pageturn effect when you go to the next page.
I now want to insert the actual group node at the start of this view. I can't put it in header or template files, as then it wont work with the ajax pagination.
I have worked out the SQL I need to get the results I want...
SELECT node.nid AS nid FROM d7_node node
LEFT JOIN d7_og_membership og_membership_node ON node.nid = og_membership_node.etid AND og_membership_node.entity_type = 'node'
WHERE (( (node.status = '1') AND (og_membership_node.gid = '42' ) )) OR (node.nid = '294')
ORDER ASC
The SQL my view is currently using is...
SELECT node.nid AS nid FROM d7_node node
LEFT JOIN d7_og_membership og_membership_node ON node.nid = og_membership_node.etid AND og_membership_node.entity_type = 'node'
WHERE (( (node.status = '1') AND (og_membership_node.gid = '42' ) ))
ORDER ASC
So basically I just need to tag on 'OR (node.nid = '294')' to the WHERE.
I'm trying to use this custom module
function hook_views_views_query_alter(&$view, &$query) {
if ($view->name == 'flipbook_ii') {
$nid = $view->args['0'];
$query->where[] = array(
'conditions' => array(
'0' => array(
'field' => 'node.nid',
'value' => $nid,
'operator' => '=',
),
),
'type' => 'OR',
);
}
}
But that is still setting the WHERE query
WHERE (( (node.status = '1') AND (og_membership_node.gid = '42' ) AND (node.nid = '294') ))
Can anyone explain a way that works?