function themekey_redirect_init in ThemeKey 7.3
Implements hook_init().
File
- themekey_redirect/
themekey_redirect.module, line 141 - Define rules to redirect the user to a different domain. The common use-case is to setup sub-domains for mobile sites. In this case you can configure ThemeKey Redirect to detect mobile clients and redirect the user accordingly. In ThemeKey itself you…
Code
function themekey_redirect_init() {
if (themekey_is_active()) {
// Not active if ThemeKey Redirect ajax callback is requested.
// Ensure to have javascript based switching for anonymous users in page cache.
themekey_redirect_add_js();
if (isset($_GET['themekey_redirect'])) {
// Don't cache the page if query param 'themekey_redirect' is set.
drupal_page_is_cacheable(FALSE);
switch ($_GET['themekey_redirect']) {
case 'active':
// User has been redirected.
setcookie('themekey_redirect_state', 1, 0, '/');
break;
case 'avoid':
//User manually selected a domain. No further redirects.
setcookie('themekey_redirect_state', 2, 0, '/');
break;
}
}
}
}