- πΊπΈUnited States bluegeek9
Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade β .
I wanted to be able to use Domain Access across environments without having to worry about how it would represent the domain. I wrote a hook_domain_load()
, taking ideas from a post by agentrickard. This allows me to set the proper domain in the ui and relay that information to the admin.
I was having trouble however actually finding the correct domain the user is actually on. I'm storing the domains using the 'canonical' domain. I found that when it was trying to lookup the domain it was of course looking for the domain that belongs to the current development/staging site, not the canonical domain that is stored in the db. I wanted to store the canonical domain that is represented by production so that I could allow most of this logic to fall through and not waste processing on prod. By adding a simple drupal_alter
in domain_lookup_simple()
, I'm able to rewrite the domain for the lookup so that it returns the right domain with the correct domain_id vs the fallback default domain_id.
This worked for me and I realize this may not be the "best" way to handle this. I've stepped through the code quite a bit and it seemed the simplest solution to handle this use case. Let me know if this is way off base or there is a better solution that I'm missing.
I've also included an option for a variable to be set for DOMAIN_INSTALL_RULE
instead of having to change the constant in the module. I didn't want to have to do this across environments as I'm building the site using a make file and would have to remember across builds vs just exporting a variable.
$rule_variable = variable_get('domain_install_rule');
$rule = isset($rule_variable) ? $rule_variable : DOMAIN_INSTALL_RULE;
Thank you,
Scott
Closed: outdated
3.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade β .