The requirement is for different pages on the website to show different Twitter feeds according to the current page. There is a context (triggered according to the path) that inserts a view block into the footer. A custom module kicks in when the query for the view block is about to be executed. The module does some simple processing to determine what Twitter feed(s) are required to be displayed on the current page.
So, the custom module contains:
/**
* Implementation of hook_views_query_alter
*/
function twitter_feed_selector_views_query_alter(&$view, &$query) {
if ($view->name == 'tweets') {
// Some processing...
$feed = _twitter_feed_lookup($matching_path);
$view->query->where[1]['conditions'][0]['value'] = $feed;
}
}
However, the view block has a lite pager and Ajax enabled. And when the user clicks on the pager links to see the next/previous page of tweets, no tweets are coming back from the view.
I can't find how to get around this. If I turn off Ajax on the view, all is well, but the whole page is reloaded each time the pager is clicked -- which is way too clunky.
Can anyone suggest a means to make my amendments to the view query work nicely also with the Ajaxed results from the pager?