This is a nice module. It does some of what http://drupal.org/project/domain does, but with less overhead -- because it doesn't try to do as much.
There is some overlap and possible collaboration that we should look at.
As far as the url() function patch goes, I would encourage you to use the custom_url_rewrite_outbound.patch instead. It is a functional backport from Drupal 6, so it provides a cleaner upgrade path.
See http://drupal.org/node/210248 for discussion and http://drupal.org/node/207330#comment-714909 for the backport patch.
The disadvantage is that your subdomain_url_rewrite() function has to move.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | custom_url_rewrite_outbound.patch | 995 bytes | setvik |
Comments
Comment #1
setvik commentedThanks :-)! I haven't had a chance yet to check out domain but will definitely do so.
The subdomain module rewrites the pathauto generated path alias (evaluated at common.inc line 1193). The patch you mentioned inserts its call to custom_url_rewrite_outbound before the call to drupal_get_path_alias, so that won't work for us in its current state.
I took a peak at the Drupal 6.0 URL() implementation of custom_url_rewrite_outbound and it looks like it executes after the path_alias call as well, passing both the pre-modified path ($original_path) and the aliased path ($path) to the custom_url function allowing it to manipulate both.
Could we do the same with this patch? The function structure between 5 & 6 is slightly different, so it's a bit tricky, but if we can do it, it'll make the custom_url_rewrite_outbound implementation a bit more consistent with Drupal 6.0 and we'd be able to replace our subdomain_url_rewrite() hack with it as well.
Attached is an adjusted patch. Take a peak and let me know if you think it would work.
The patched portion of the url() function:
- Stein
Comment #2
setvik commentedUpdating status to patch (code needs review)
Comment #3
agentrickardThat's interesting. Two of us intercepted the patch that was going into 6 in order to change it for our needs -- originally, it did not let you overwrite the $base_url, either.
You might want the custom_url_rewrite_inbound() function to capture and alter the path alias. But I am not sure why you need to alter the path alias in any case.
If not, your patch should be submitted for consideration in Drupal 7.
It is interesting to me that you have not looked at Domain. There is a large thread on the Drupal developer's list right now about duplicate effort. But it appears that we are trying to solve different problems. You could make Domain do what Subdomain does by using the API, but if you do not need the node access overhead, why bother.
The use-case for Domain is to run multiple affiliate sites from one install -- sharing content as needed. Subdomain has a narrower focus -- one which people have asked for previously.
From my point of view, I would just warn you to avoid feature creep. Keep this a simple solution.
We might consider comparing feature requests once in a while, and swapping some shared code.
One question -- which does not have to be answered here -- is if you have run into any issues where your code is not available soon enough in the load cycle. I have to use hook_init() and, in some cases, add code to settings.php to ensure that certain variables are available when they are needed.
It might also be interesting to see if some of the Domain helper modules -- Domain Theme, for instance, could be abstracted for use with Subdomain.
Comment #4
setvik commentedThanks for the pointer to custom_url_rewrite_inbound(). I didn't realize that Drupal 6 gave us the ability to modify the inbound path.
I could grab the subdomain from $_SERVER['HTTP_HOST'], get it into the path, and then i wouldn't need custom Apache URL rewriting; drupal would handle both ends.
If there are areas you think we can collaborate, definitely let me know. I'm swamped at work and haven't had a moment to install or try out Domain yet, but will hopefully be able to in the next couple of weeks.
I released subdomain b/c I wanted to get more involved with the community and give back something that we've found useful and some other people have been asking about. I ran across the domain project page right before releasing the module, but in my cursory reading, thought it had more to do with access controls and connecting separate Drupal sites on different domains than simple URL rewriting...
Re-reading through Domain's module page now, though, i think i may have misread it the first time. uff-da.
Basically, my vision for subdomain is to create a lightweight, easily-configurable subdomain URL rewriting plugin for Drupal... put another way, I want to subdomain-enabled pathauto. No changes to node access. In terms of future features, i was planning to enable a taxonomy vocabulary mode, so that people could select a taxonomy vocabulary whose terms (and content) would be placed on their own subdomains. And possibly adding some granularity to node author subdomains to allow placing users in specific roles on different subdomains:
Something like:
http://writers.example.com/mary
http://writers.example.com/betty
http://editors.example.com/jon
http://editors.example.com/madeline
Based on your understanding of Domain and Subdomain, what do you think would be best? Does Domain already provide all the above functionality? If so, would it be best to scratch this module to avoid confusion? If not, would it be best to integrate subdomain functionality into domain or maintain them separately and just ensure that subdomain's scope is specific and limited. I definitely don't mind integrating it into domain. If we end up keeping them separate, i would rewrite my module page description to make it much more concise and include a short description of functionality provided by the domain module and point people towards it.
e.g.
If you need [need goes here], subdomain will suffice.
But if you need [needs go here], domain is the way to go.
Let me know what you think would be best.
speaking of core patches, is subdomain-based-path-alias functionality something we should submit for inclusion into core.
i.e. so that inbound subdomain-based urls would translate to the correct drupal internal path and URL rewrites would incorporate the subdomain info when generating outbound urls. What do you think?
Looking forward to hearing from you,
- Stein
Comment #5
agentrickardsubdomain-enabled pathautois a great description, and not at all similar to what Domain tries to do.I think that Subdomain solves one problem and Domain Access solves another. Not using node_access keeps you module lightweight. So I do not see this as duplication.
In fact, I just added a link to Subdomain from the main module page.
Comment #6
setvik commentedCool, thanks!
I'd like to do the same on subdomain's homepage. Can you recommend a 1-2 sentence summary of the domain module i could use to point people towards it?
Comment #7
agentrickardComment #8
Fayna commentedSubdomain would suit my needs more than Domain would, so I'm sure its the same for others. No need to trash it!! :) Great job!
Comment #9
agentrickard@Fayna
Right. Subdomain is very cool, and linked to from the Domain Access page. Different solutions for different problems.
Comment #10
setvik commentedComment #11
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.