Use case
I need organic groups to be accessible both via a subdomain (group1.mydomain.com) and via a full domain (group1.com). I want to use spaces_og and purl. Both cases work perfectly fine, but currently it is not possible to assign more than one type to a provider.
Implementation
Purl is not far away from being able to do this. It already lets all enabled methods/processors detect if they want to act. Hacking away on function purl_modifieres() I was easily able to achieve what I want. There's mostly two parts missing currently:
1) The UI (both the admin UI where you configure the enabled methods for each provider, and purl_form() to provide text fields for all enabled methods of the provider)
2) I'd have to store the method for each entry in the purl table in addition to the provider.
Does this approach sound reasonable? I will likely write a first patch for this in the next days as we'll need this soon. If anyone has some more suggestions or insights it would be greatly appreciated.
Totally unrelated, but the part that confused me the most when reading the purl source code was the constant switching between type, method and processor. It took me quite a while until I found out that they are all (nearly) the same.
Comments
Comment #1
jmiccolis commentedFirst off, sorry about naming confusion in purl. I agree it could be improved and documented better. Thanks for bearing with me.
I need to think about this more, but I'm not sure I like having multiple processors target the same provider.
Have you looked at writing a custom processor that is the funky combination of the domain & subdomain which you need? Recent changes in purls internals should make it fairly quick to write this.
Comment #2
Frando commentedWell yes, I could of course write a custom processor. But I would still have to be able to store more than one entry for a single OG. I'll investigate some more in the next days. One solution might be to give more power to processors, e.g. allowing them to hook into purl_form() and its save part so that I could extend the form and save the second entry via a custom processor.
Comment #3
jmiccolis commentedRight, I'd forgotten about the need to store multiple values.
One other thing to consider is that we've been talking about moving storage of prefixes into a more sensible place as well. As you may have noticed there are some place where we pass a `null` value around to signify that a prefix map isn't needed and the and the provided value can be used natively. For example this happens with path_pair. I'm open to ideas about restructuring this.
Comment #4
johngriffin commentedI am using spaces_taxonomy and purl to create the appearance of several different sites. There is no global site as such, so we want to make sure that the user is always in a space. I think that having the ability to set the type (processor) per modifier would allow us to achieve the URL structure we're aiming for, something like:
www.example.com -> space 1 (domain type)
www.example.com/space2/ -> space 2 (path type)
www.example.com/space2/space3/ -> space 3 (path_pair type)
Obviously if this were possible then I think we need some sort of weighting system, or at least some rules for which type takes precedence over another. In the example above we would want path_pair to match before path, and path to match before domain.
Does anyone else have a similar use case? We are looking at writing a custom processor to achieve our needs but if there is more demand for this type of functionality then it may be worth looking at adding it to purl.
jmiccolis - it would be great to get your take on this, I know that you say that you don't like the idea of multiple processors targeting the same provider above, is this purely because of the additional complexity it would introduce? If you're really against this then how would you suggest implementing the use case I've outlined above?
Thanks!
John
Comment #5
Frando commentedJust for the record, I went with a custom processor in the end. The specific requirements of the project allowed us to do this without actually saving two strings per space, we got along with some (quite hacky) string manipulations to get from the group's domain to the group's subdomain. Not generally usable but solved my specific usecase.
Comment #6
johngriffin commentedThanks Frando. Would you mind sharing your code for the custom processor? I think we'll go down the same route but when we tried to do a proof-of-concept we had trouble exposing the processor class and getting purl to recognise it. Would really appreciate it if you could share, either publicly or privately if that's not possible.
Comment #7
johngriffin commentedIn case it's useful for anyone else, when I came back to this it seems relatively trivial to expose your own processor! Just implement hook_purl_processor and clear the cache. E.g.
Comment #8
johndoe123 commentedhi, have you guys been able to implement this? i need this functionality as well.. i need both subdomain and path per modifier
Comment #9
rbrandon commented