Ajax pager failure in view after modifying view on hook_views_query_alter 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(&amp;$view, &amp;$query) {

  if ($view-&gt;name == 'tweets') {

    // Some processing...

    $feed = _twitter_feed_lookup($matching_path);
    $view-&gt;query-&gt;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?
When the view query is being called from inside the pager, the requesting URL is different. It becomes: '/views/ajax'. This URL does not match any that had been specified in my context, so no results were returned.

I solved the problem by checking if the query view is being called within the pager -- i.e. if $_SERVER["REQUEST_URI"] == '/views/ajax'. If so, then I extract the correct path instead from $_SERVER["HTTP_REFERER"]. If not, then it's okay to accept the path from $_SERVER["REQUEST_URI"].