We're setting up OA2 as a portal site for our customers and using the Domain feature to give each client space a unique subdomain.

So our site structure looks something like this (all of the items are spaces):

The problem is that the subspaces do not inherit the domain settings of the parent space and thus they end up with a URL path of http://ourportalsite.com/project1 instead of http://client1.ourportalsite.com/project1.

If we set the domain on the subspace to be the same as that on the parent space then the URL works as expected, but the built-in breadcrumb navigation doesn't work since it only links to the domain, not the domain + subspace path. This results in all of the subspace navigation links going back to the parent level space rather than the subspaces.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpotter’s picture

Yes, I'll add this to the list for a future release.

shawn_smiley’s picture

Thanks mpotter.

I'll see if I can get one of our devs to work on a patch to add this support.

Do you have any preference on if we make parent settings be inheritable by subspaces or if we update the breadcrumb navigation to include the full path to subspaces with domain settings?

Obviously any guidelines or pointers about how you would like to see this implemented would be much appreciated.

mpotter’s picture

By default a subspace should probably inherit the domain of the parent. That seems to make the most sense. Then a subspace can override this by providing it's own domain.

Argus’s picture

Title: Subspaces do not inherit domain settings » Make subspaces inherit domain settings
Status: Active » Needs work
kengilb’s picture

kengilb’s picture

Status: Needs work » Needs review
kengilb’s picture

My apologies, I forgot to account for subspaces of subspaces.

kengilb’s picture

Project: Open Atrium » Open Atrium Core
mpotter’s picture

I'll take a look at the patch, but I will probably generalize it a bit because there are several other properties of spaces that are also not currently inherited, including: colors, banners, etc.

hazit’s picture

Hi there

Sorry to be posting such a simple question here, but I cannot find any trace in any of the documentation or OA support material on how to set this feature up.

I have a registered domain name which I add to the space, but nothing seems to happen. I go to see if I should be changing the url alias but it does not seem to allow users to use anything other than the main domain.

And yes, if I can get the space-as-domain working, it would be great if I were able to have all the subspaces consistently follow the same domain name rules also.

mpotter’s picture

To set up a domain for a space, you need to set the domain field for the space as you did, but you also need to go to the admin/openatrium/setting page and set the default domain name that you want to use for the rest of the site.

For sub-space support the patch is in #7. The patch is still in "needs review" state. It has not been committed to the code yet.

mpotter’s picture

Status: Needs review » Needs work

This still needs work.

The patch in #7 only changes it for the actual subspace node and not the content nodes within the subspace. The proper way to do this would be to modify the oa_domains_get_space_path() routine to check for parent paths. Probably also need to make the $space_id of that function pass-by-reference so it can be updated with the id of the parent space that has a domain set.

hazit’s picture

RE#11 Thanks Mike - your comments were really helpful and now the domain-per-space is working like a charm. Looking forward to the inheritance functionality as this will also be very useful. Thanks for all your great work.

marqpdx’s picture

hi Mike and everyone, Thanks for all this. I can confirm it is working for me.

I now need to make the content piece work as well for domain subspaces (per #12).

Mike, the patch in #7 changes oa_domains_url_outbound_alter() to account for parent domains and the full path.

To account for content nodes in the subspace, you suggest we update oa_domains_get_space_path().

Would it make most sense to roll back the patch in #7, and update oa_domains_get_space_path() to cover parents for both subspaces, and subspace content?

I'm willing to have a go at the code (unless you have a version ready to go), but i wanted to get direction about how best to modify the module.

Thanks,
m

mpotter’s picture

Yes, I think doing it in oa_domains_get_space_path would be the best general solution and would love to have help with that.

marqpdx’s picture

hi Mike,

i made a change that now allows the creation of sections and other content as part of the subspace.

i merely cloned the new section of code from #7 to apply to the content section.

but, what doesn't yet work is create a new User Group.

it doesn't appear that oa_domains_get_space_path() is called anywhere outside the domain module.

Do you know where the group creation logic would need to be adjusted to account for extended domain paths?

thx,
m

marqpdx’s picture

Actually, my bad about the User Group not catching the parent path. This appears to be working.

A parent group was not set automatically during group (which is correct behavior, i just didn't notice).

Sorry about that.

Thx,
m

mpotter’s picture

marqpdx: do you have a patch to upload?

marqpdx’s picture

I will make a patch.

Should i make the patch against the result of the #7 patch above, or make a patch against the released code (meaning it will have the #7 changes plus mine)?

Haven't done it before, but i'll figure it out. Just let me know which patch you want?

thanks
m

dsnopek’s picture

@marqpdx: The new patch should include all the necessary changes, so: yours plus the changes in the patch from #7.

marqpdx’s picture

marqpdx’s picture

ok, here's my first ever patch, so yay. i hope i did it correctly.

i did it against the 7.x-2.x, and it accounts for both use cases above, the subspace and the content. in either case, the parent domain has to be in the inheritance.

let me know if i did it incorrectly.

thanks,
m

ps - the code is the simpler solution; i didn't refactor, just added the #7 patch solution to the next section down.

dsnopek’s picture

@marqpdx: The patch file you uploaded is empty. :-/

marqpdx’s picture

that was lame. sorry about that.
at least there were no errors :-)
correct one coming.
m

Argus’s picture

Status: Needs work » Needs review
marqpdx’s picture

So now i am finding that when i try to create a webform, it doesn't pre-pend the domain time (e.g. subsite1.domain.com/content/webform/webform1). hence, error.

I will look into the webform node_save() - unless there is a cool Open Atrium way i don't know about.

thx
m

ps, anyone use that patch?

gaele’s picture

Status: Needs review » Needs work

@marqpdx: the patch you uploaded in #24 is exactly the same as the one in #7.

gaele’s picture

Project: Open Atrium Core » Open Atrium Domains
Version: 7.x-2.12 » 7.x-2.x-dev
hefox’s picture

Project: Open Atrium Domains » Open Atrium
Component: Miscellaneous » Domains App

Using one issue queue (open atrium) for all app issues.

Interesting that can assign an issue to a project that has issue tracker disabled...

gaele’s picture

marqpdx didn't upload the right patch, so I'm working on it myself. Just to be sure, this is what we're talking about:

Right?

Argus’s picture

Yes, and especially the last step for subspaces, they do not yet auto-inherit the domain settings.

gaele’s picture

Status: Needs work » Needs review
FileSize
4.17 KB

Attached a patch that I tested with a couple of spaces, subspaces, sections, content nodes and custom domains. It seems to work as long as it doesn't get too complicated. (If both a space and a subspace have a custom domain, the permalink creation goes wrong.)

I had a hard time figuring out how this all works and should work, as I am not really familiar with OA. On the way I did some refactoring.

The next few days I'm available to help out, after that I will be away for two months.

Argus’s picture

Tested the patch and it seems to work fine.

Argus’s picture

In admin/content the links sometimes are displayed incorrectly, namely without the subdomain. This occurs only when admin/content is viewed from another subdomain.

Say I have 2 private Spaces: site1.example.com and site2.example.com and site2.example.com has a subspace called "mysubspace" with a News Section.
Documents created in this section can be seen in site1.example.com/admin/content (imho they shoudn't because both Spaces are private and so content in them should also be private, but that's another matter), but they link to example.com/mysubspace/sectionname/nodetitle instead of site2.example.com/mysubspace/sectionname/nodetitle like they should.

hosais’s picture

@Argus
I am also testing this. As I mentioned here https://www.drupal.org/node/2265627#comment-9464243, you will see posts of other domains if you have privilege to access the space (no matter what domain it is). So "both Spaces are private ..." I think it is correct behavior. Do I misunderstand you? (Are you saying that some user can see the private info but he/she is not the member?)

Your latest point seems that the domains are not correct but my part looks good. I even changed the parent of one sub domain. After refresh few times, all the links are changed correctly. Do you clear the cache when you tested? It does not work for me until I clear the cache. (I also restart the web server. Well, I am not sure exactly how the replace domain works here).

hosais’s picture

I have one issue here though.

When I do admin/content, the links are with different domains correctly; however, I can access every spaces/contents (if I have right to access) with the wrong domains by type it directly in the address in browser.

For example, you can access both domain1.example.com/subspace1 and site2.great.com/subspace1
Or domain1.example.com/subspace1/document1 and site2.great.com/subspace1/docuemnt1

About domain1.example.com and site2.great.com you can access by the path alias. For example,
site2.great.com/domain1_example domain1.example.com/sites2_great

This for me is wrong behavior and may have problem of SEO.
About SEO, since it is not related to inheritance, I create another new post here: https://www.drupal.org/node/2409843

hosais’s picture

Since it did not work in the beginning so I traced the code. (After clean the catch and refresh few times it works)

Just curious: two quesion about the patched code

while ($parents = oa_core_get_parents($nid, OA_SPACE_TYPE)) {
        if (count($parents) > 1) {
          // inherit from the last called parent
          //$custom_path = $base_url . '/' . $node_alias;                             <-- should remove the if part
          //break;   
         }   
   ......

This code is handling if the parents (direct parents, not grandparents) has more than one.
The code is not finding the last called parent. It is the base domain.
In this case, the behavior definition actually is NOT clear, since two parents' domains may end up with different domains and which one should be it? Currently, I suggest just pick one of it => so this "if body" should do nothing (= one parent, choose parent[0]).

In my use case, it should has only one domain since all the subspace should has only one same domain ancestor. With this definition, just pick one of them is OK. That I suggest define when a space has two parents, just pick one of them and the admin need to maintain it correctly or some error message or prevention put into the code. What do you guys think?

=========================================================
Note: My test procedures are with two domains.
a.One is base domain. Two space here with some contents.
b.Another domain2 (NOT the base domain) has 3 sub-spaces which have one news section and one news content.
Domain2 space->course->business course->sub_B1course
only domain2 has customized domain.
c. add a parent to sub_B1_course. The parent has different domain from Domain2. To see how it works.

hosais

dsnopek’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #32 is working for me in my local dev environment. It's going to get some testing in production soon too. :-)

The only thing that concerns me in the code is a little bit of duplication - we see this same (more or less) code block twice:

        // this is a node within a space, check custom domain of space
        $space_alias = drupal_get_path_alias('node/' . $space_id) . '/';
        // check if node_alias begins with space_alias
        if (substr($node_alias, 0, strlen($space_alias)) == $space_alias) {
          // remove the space alias from the beginning of the node alias
          $node_alias = substr($node_alias, strlen($space_alias) - strlen($node_alias));
        }
        $custom_path = $base['scheme'] . '://' . $space_path . '/' . $node_alias;

That said, this isn't the worst sin! But if it could be done without duplicating this code, that would be better. :-)

dsnopek’s picture

gaele’s picture

Re #37: As I mentioned I'm not that familiar with OA Domains. You're right that this is a strange piece of code. I based my patch on #7, and left this part as I wasn't really sure what it is about. If you think this can be improved go ahead.

Re #38: Yup, that's ugly :-) I cleaned up quite a bit just to understand what is going on in the code. More refactoring seems possible, but that decision is probably up to the maintainers? I didn't feel comfortable both adding a feature and changing so much code.

Argus’s picture

Any chance for this patch to get commited?

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

I updated this patch from #37. Regardless of how many parents there are, the first parent is always the direct parent for inheritance. Didn't do anything for #38.

Did some testing and it seems to be working well. Committed to 9a79de1 of oa_domains.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.