What I did in our project was that to look for pjax header in the request, if the pjax header is present then load the content template only else load the full template, this is my corresponding code in perl, hope it helps
sub tour {
my $self = shift;
return $self->render(
template => 'static/tour',
layout => $self->req->headers->header('X-PJAX') ? 'content_header' : 'full_width',
);}
you can implement the same in php