I'm using spaces_taxonomy and purl to create a multisite-like architecture. We don't want users to ever be outside of a space, but if they visit a URL which doesn't specify a space in the path then we'd like to redirect them into a default space. We'd also like to not have to use a path prefix for this space, so that it appears to be the global site. I.e.
www.domain.com -> sets "global" space and returns front page
www.domain.com/node/1 -> sets "global" space and returns node/1
www.domain.com/term/ -> sets space that "term" PURL modifier is associated with
Would this require a large change to the spaces architecture in order to make it work? I'm hoping that it can just be done by a module stepping in after spaces has run, then if no space has already been set, setting the default space. I'd appreciate it if anybody with the same requirements could let me know, if this functionality doesn't already exist somewhere, and my approach is valid, then I'll likely write to module to achieve it.
Thanks,
John
Comments
Comment #1
nedjoHave you got to this yet? Looks like it would be a relatively simple addition, maybe involving:
* A settings page to set the default space by type and ID.
* At an appropriate stage, detect if there is a current active space and, if not, initialize the default.
Comment #2
johngriffin commentedHi Nedjo, we did try this using pretty much exactly the code that you've proposed.
We came up against the following problems:
1. If you want to avoid patching spaces then where should this be done? If you put it in hook_init then it'll only get called for non-cached pages. Hook_boot happens too early, spaces hasn't been included yet. Unless there's a trick I'm missing here it looks like spaces will need a patch or a hook added to allow another module to set a default space if it does not find one.
2. When spaces_init_space() runs, spaces will instruct purl to set the URL accordingly. In my use case I want the default space to have no modifier in the URL, the default space should be transparent to the user, without any path prefix, subdomain or anything else being present in the URL. I think this is predominantly an issue for PURL though, I'm looking at creating a custom processor which will allow you to specify no modifier for the default term. Either that or you allow the modifier type to be set per term, which would mean that the default space could use the domain modifier type, which would match after no path prefixes, subdomains or anything else are found in the URL. Sorry for the complex terminology! There's an issue about this here: http://drupal.org/node/659454
Comment #3
johngriffin commentedI've just released a module to address this problem. It exposes a purl processor called path_default, allowing you to set a modifier to have no effect on the path. We used this to trigger spaces to be activated with no modifier in the path, giving us a default space that would always be activated if no others were.
See: http://drupal.org/project/purl_default