I have some custom PHP code in a View header to load a different image based on the URL. The View works fine on it's initial load, but as soon as I change any of the filtering options with AJAX enabled, the Header disappears. Example code:
$req = $_SERVER['REQUEST_URI'];
if (preg_match("/TEXT-IM-LOOKING-FOR/", $req))
{
...HTML HERE...
}
I checked the URI by printing $req with dpm() and it's coming back with the text I'm looking for in the string, it just fails to reload the header for some reason. If for some reason this can't be done, is there any way to retain the header and only reload the body of the View?
It's almost never a good idea to put HTTP headers in a template/view for exactly the reasons you're citing. Switching to AJAX (in drupal) appears to change (maybe delete) the headers being sent.
You should instead try to put this code in a controller before it reaches a template/view.