1

I want to add a persistent query string to pages once it is introduced (for the context module to maintain a page layout inside an iframe). At the moment, I'm checking the http referer for the string and redirecting to the current url + query string.
This works fine, except:

  1. It's an extra page load. Not a big issue as it's an admin page inside an iframe that's not used much.
  2. It breaks batch pages. I think I can get around this by checking if arg(0) is "batch" and then add the referer to $_session and then check for it.

This seems really convoluted, hacky and prone to breaking the site for a user if I don't get the session variable deleted straight away.

hook_url_outbound_alter() doesn't work for forms unfortunately so is there a better way?

0

The way I would go about this would be to dedicate an alias subdomain and perform the redirect before hitting the application.

For example, Apache can be configured via mod_rewrite to add any query parameter to the requested URL:

  # Add iframe=1 to query parameter if requested from iframe domain.
  RewriteCond %{HTTP_HOST} ^if.example.com [NC]
  RewriteCond %{QUERY_STRING} !iframe=1 [NC]
  RewriteRule ^(.*)$  http://if.example.com/$1?iframe=1 [L,R=301]

The only problem this causes is that D7.5 now forcing iframes to only originate from the same domain so you'll have to explicitly allow iframing from this different domain in your settings.php:

# Allow iframing on host requests to the iframe domain
if ($_SERVER['HTTP_HOST'] == 'if.example.com') {
  $conf['x_frame_options'] = '';
}
0

I believe this is something the PURL module was designed to do (persistent query string):

https://www.drupal.org/project/purl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.