This is kind of in the same category as https://drupal.org/node/2159443 but felt it probably belongs in a different issue as they are not dependent on one another. I wanted to rewrite the subdomain and path that are presented to the admin at: admin/domain/content or the Affiliated content page. I need this so that I can easily use this functionality over dev/stage environments. I created a patch that adds a drupal_alter() so that both the subdomain and path can be overridden in this case.

The resulting alter looks something like this:

function HOOK_domain_content_subdomain_alter(&$subdomain, &$path) {
  $server = MY_MODULE_get_server(); // Returns the subdomain of the $_SERVER['SERVER_NAME']
  $url = parse_url($path);
  $parts = explode('.', $subdomain);
  if (count($parts) == 2) {
    $subdomain = $server . '.' . $subdomain;
  }
  else {
    $subdomain = array_shift($parts) . '.' . $server . '.' . implode('.', $parts);
  }
  $path = $url['scheme'] . '://' . $subdomain;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scottalan’s picture

scottalan’s picture

Issue summary: View changes
agentrickard’s picture

Why is hook_domain_load() not sufficient in this case?

agentrickard’s picture

For all these issues, please also see #1303616: Allow alias registry for auto-creation which I think would be a huge help.