Integrate with URL Alter module
| Project: | Domain Access |
| Version: | 6.x-2.0-rc9 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
I have been working on a multisite drupal powered website for about 6 months now and everything seems working well.
Just of recent I found out that my site does not optimize urls. I mean it resolves it only to the base path and not sub-paths.
So I tried to make use of url alter module to help with sub-paths. But since domain moodule makes use of custom_url_rewrite_outbound and url alter module makes use of hook_alter, I then could not go ahead with the removal of domain module's settings_custom_url.inc file.
I have checked series of community posts and all I could find is that I have to look for a way to make custom_url_rewrite_outbound function work without conflict.
But I don't know how. Can anyone help please.
Thanks.

#1
Cross-posts are generally frowned on.
It looks to me like it should just work with Domain Acccess rc8. Though you may have to remove lines 16-20 of DA's settings_custom_url.inc.
#2
@Dave Reid
We addressed this issue in DA rc8, so I am unsure how this module now plays in. In fact, it looks like the two modules will no longer work together, since DA know checks for the precense of custom_url_rewrite_outbound() in a manner similar to url_alter.
See #450344: domain module steals custom_url_rewrite
I suppose I can change that behavior and require this module instead, but would hate to introducce the dependency at this date.
#3
I've been looking into this. Here's my possible solution:
1. Set the url_alter to have a ridiculously low weight so it is the first module that is loaded in a full bootstrap. Therefore it gets to be the only module that implements the custom_url_rewrite functions.
2. Move the custom_url_rewrite_outbound stuff into domain.module so that it can be loaded after url_alter and since it is only needed on a full bootstrap (for use with url() and l()). Also remove the settings_custom_url.inc file.
Ignore the changes to settings_custom_url.inc in the patch. That file would be removed in this method.
#4
We can also try this. Add these to url_alter() module. Doing so will force the module to load early enough in the bootstrap to run correctly with DA.
<?php
function url_domain_boostrap_full() {
// Do nothing, but force our module to load.
}
function url_enable {
domain_bootstrap_register();
}
function url_disenable {
domain_bootstrap_unregister();
}
?>
But even then, I would need to change the name of my function.
#5
Moving back to my queue
#6
Probably need to change the install instructions also.
#7
Yes.
#8
Because of how Domain Access loads, we cannot insert the !exists logic directly into the module. We have to run that check inside hook_init(), which keeps our version from loading before url_alter module's.
The attached patch tests clean, and includes new documentation. Note that I kept domain_url_rewrite_outbound() as a legacy wrapper function.
I should also note that this line of url_alter.module consistently failed for me:
<?phpfunction url_alter_url_alter_outbound(&$path, &$options, $original_path) {
if ($code = url_alter_var('outbound') && !isset($_GET['url-alter-kill'])) {
// We can not use drupal_eval() here since we need to be able to modify
// the $result variable.
eval($code);
}
}
?>
I had to remove the !isset part of the IF in order to implement stored rules for path rewrites, even when the code was valid (such as $path = 'a';).
#9
Updated patch, committed to HEAD.
#10
@agentrickard: Woot! I'll look into #8. Looking forward to figure out the next Domain Access integration problem: XML sitemap.
#11
Automatically closed -- issue fixed for 2 weeks with no activity.
#12
Follow-up notice that I'm going to be committing a new version of the URL alter module that changes the hooks to hook_url_inbound_alter() and hook_url_outbound_alter(). This is for consistency with the hooks that were accepted into Drupal 7 (#320331: Turn custom_url_rewrite_inbound and custom_url_rewrite_outbound into hooks)!
Please update domain_url_alter_outbound() to domain_url_outbound_alter() as soon as you can since I'm creating the new URL alter release tomorrow. Plus this will make your module one-step closer to being Drupal 7 compatible (then you can even drop all the custom_url_rewrite juggling)!
#13
Here's a new patch against HEAD/rc9
#14
Committed to HEAD.
#15
Automatically closed -- issue fixed for 2 weeks with no activity.