We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39234
    • 7 Posts
    Hi there,

    I got two contexts in my installation. Each contex has its own domainname.
    In the first context (web) I got a folder with the content for the website.

    The second context shall take the content from the folder of the first context (web)

    When I call the Domain of the second context the site apear fine. With getResources I list a view resources from the folder of the first context (web).
    BUT, when I click on the content item to see the fullview I get an error 404.

    What can it be?
      • 22303 MODX Staff
      • 10,725 Posts
      Is the URL being generated correctly? How are you switching Contexts? How are you forwarding to the Resources in the web Context when users are accessing the other domain's Context?
        • 39234
        • 7 Posts
        I switch the context inside the index-php like so:
        /* setup for multiple domains */
        switch(strtolower(MODX_HTTP_HOST)) {
           case 'www.name-context1.de:80':
           case 'www.name-context1.de':
              $modx->initialize('web');
              break;
           case 'www.name-context2.de:80':
           case 'www.name-context2.de':
              $modx->initialize('con2');
              break;
            default:
              // by default / if no other rule can be applied, load 'web' context
              $modx->initialize('web');
              break;
        }


        The link is generated like so:
        http://www.name-context2.de/index.php?id=300
        It seem to be correctly

        Forward to the resources:

        I list the resources via getResources:
         [[getResources?  &parents=`47` &showHidden=`1` &tpl=`tplTitelFirstView` &includeTVs=`1` &processTVs=`1`  &limit=`1` &tvFilters=`nrtContent.portal==%det%,detContent.start==%Ja%` &context=`web`]]


        Inside the tplTitelFirstView chunk:
        ...
         <a href="[[~[[+id]]]]"><img src="[[+tv.nrtContent.titelbild]]" width="438" height="238" border="0" title="[[+pagetitle]]"></a>
        ...
        
          • 22427
          • 793 Posts
          May be it would help to insert the Site URL of the web context into the link:
          ...
           <a href="http:/ /www.name-context1.de/[[~[[+id]]]]">.....</a>
          ...
          (Omit the blank between the slashes)
            • 39234
            • 7 Posts
            If I put the site URL hard coded inside the link, it could couse a lot of problems. It is important that the user dont see the link of context-1 when they are in the context-2 domain.
              • 39234
              • 7 Posts
              I found a system setting "allow_forward_across_contexts" which was set to no. After I set it to yes I did not get the 404 nomore but now it redirect to the startsite of context-1 when I click on the content item.

              Any suggestions about the problem?
                • 39234
                • 7 Posts
                Still on the same problem. Look like MODx can not handle cross context content (?) I did not finde a solution, yet.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  It handles it fine. Do not cache the site_url anywhere in your cross-context content however. If a context is meant to server multiple site_url's, then make sure you do not set that setting in that Context, allowing the client requested HTTP_HOST determine the actual site_url (which is MODX's default behavior until you set site_url, base_url or other settings in the System or a Context).
                    • 39234
                    • 7 Posts
                    I delete all this settings from the context (site_url, base_url) and clear the cache. But it is still the same.