Linking to content on a different site

Enonic version: 6.9.2
OS: Windows 7

Hi. Is it possible to create a content on one site that links directly to a content on a different site? We have Site A running on https://insert-domain.com/pilot/no and Site B running on https://insert-domain.com/pilot/dk, and we would like to create a content on Site A that links to a content on Site B. We’re using vhost-configuration.

We have already set this up, but when clicking on the link on Site A we get 400 Bad Request - URI out of scope.

Hi Eivind,

Do they (the two sites) run on the same server? (visible in the same Content Studio)
How does your portal.pageUrl() call look?

The two sites are running on the same server and both are visible in the same Content Studio.

The link looks like this in the content:

"optionlink": {
      "_selected": "content",
      "content": {
        "content": "19d13136-33a2-4fbf-b15a-c1e5d0b9321d",
        "target": "_self",
        "type": "server"
      }
    }

The call to portal.pageUrl looks like this:

var url = libs.portal.pageUrl({
      id: optionlink.content.content,
      type: optionlink.content.type || 'server'
});

In admin-preview the url looks like this in the markup: /admin/portal/preview/draft/no/karriere-og-laering/gjensidigeskolen

In the portal it looks like this: /pilot/dk/ansatte/_/error/400?message=URI+out+of+scope

This is due to the Vhost mapping. You are creating a link to a content located outside of the current vhost mapping.

I guess you have 3 mappings:

  1. insert-domain.com/pilot/no -> /portal/master/no
  2. insert-domain.com/pilot/dk -> /portal/master/dk
  3. /admin -> /admin

It works in admin because both site are in the same vhost mapping. But not in portal because then they are in 2 different mappings.

So I can think of 3 solutions (but somebody has maybe found a better solution)

  1. You put these two sites in a same vhost: You could have a mapping “insert-domain.com/pilot” -> “/portal/master”. But it might be problematic if there are some other unrelated sites, so maybe:
  2. Put these two sites under a common parent and have a mapping “insert-domain.com/pilot” -> “/portal/master/parentname”
  3. Or you create the URL yourself. You know what host the link is supposed to point to, and you can retrieve the content path and concatenate both. But then the link in admin would not be the one you want

So I would choose the second solution

3 Likes

Essentially the problem here is that XP does not know what vhost a site is using. We are working on a solution for this that will allow XP to create links between two live sites…

The reason this works in content studio is because there everything is running in the same vhost.

Thanks Glenn, it looks like suggestion 1 will sove this issue for us.