Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
}
Comment | File | Size | Author |
---|---|---|---|
#1 | domain_content-alter_subdomain_and_path-2176221-1.patch | 748 bytes | scottalan |
Comments
Comment #1
scottalan CreditAttribution: scottalan commentedComment #2
scottalan CreditAttribution: scottalan commentedComment #3
agentrickardWhy is hook_domain_load() not sufficient in this case?
Comment #4
agentrickardFor all these issues, please also see #1303616: Allow alias registry for auto-creation which I think would be a huge help.