We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45063
    • 40 Posts
    Benjamin Abel Reply #1, 13 years ago
    For testing purposes I created a clean cloud with one resource and one template. Also, I created new context with translation of first resource. The problem is, when I'm trying to view resource in translated context (the default is "web", and translated are "Russian") it displays resource from "web". Permissions are fine: Administrator: 0, anonymous: load, list, view. I used this guide: http://designfromwithin.com/blog-webdesign-development/2012/01/12/modx-multilingual-setting-up-babel-and-have-a-website-with-multible-languages/. I can reach translated resource only by placing it in "web" context.
    PS: Babel is fine, because I have the same problem even without him.
      • 22303 MODX Staff
      • 10,725 Posts
      You'll have to explain how you are routing requests to your non-default Context( s ).
        • 45063
        • 40 Posts
        Benjamin Abel Reply #3, 13 years ago
        Quote from: opengeek at Sep 10, 2013, 11:50 AM
        You'll have to explain how you are routing requests to your non-default Context( s ).
        With [[Babellinks]] or {server_protocol}://{http_host}{base_url}{cultureKey}/ as site_url property. So, the link looks like http://site.com/ru/.
          • 3749
          • 24,544 Posts
          Make sure you have a Context Access ACL entry for the (anonymous) user group for each Context, with a Minimum Role of Member and a Policy of Load only (IOW, just like the one for the 'web' context).

          If the users are logging in first, make sure you use the &contexts property with a comma-separated list of all front-end contexts to log them in to all contexts.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 45063
            • 40 Posts
            Benjamin Abel Reply #5, 13 years ago
            Thank you all, I solved the problem with routing, but now, another one: I have two domains. The sites are really familiar. The only difference is stylesheet and some minor content. So, when I specify site_url all the links on domain2 are pointing to domain1. When I remove site_url, links on domain2 leads to domain2 main page, i.e they are broken.
            The point is: I don't want to copy all context. I just need to duplicate ONLY the resources what was changed. Can I do that or copying entire context is the only option?
              • 3749
              • 24,544 Posts
              Are you using the tag uncached?

              [[!++site_url]]


              That's necessary when you have multiple domains. You may also need to create and set a site_url Context Setting for each front-end context.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 45063
                • 40 Posts
                Benjamin Abel Reply #7, 13 years ago
                Quote from: BobRay at Sep 20, 2013, 01:41 PM

                That's necessary when you have multiple domains. You may also need to create and set a site_url Context Setting for each front-end context.

                I must set all the tags uncached? Or just site_url in the base_href? Site_url/Base/Start/Host is seted up.

                I've been solving this for days, actually. For better understanding: One modx installation. Two different domains (registered, ofcourse). In the manager: "web" context full of resources and "web2" context ONLY with one Home resource for site start (Also, I tried the same sitestart as in "web"). I did all the preparations, so domains work fine. I have domain1.com and domain2.com and they displaying the same content correctly. But when I duplicate resourse from "web" to "web2" changing it, clicking "View" - I see the good, but old resource from "web" context. Why does it happen?
                  • 3749
                  • 24,544 Posts
                  It might be because new versions of MODX save a uri for each resource and that might not get changed when you move it to another context (or it might get changed if you just edit and save the resource in the new context).

                  You can click on the "Freeze URI" checkbox to see the resource's current URI value.

                  It could also be because of the site cache if the second resource has the same alias.

                  I think only the tag for the base_href needs to be uncached.

                  I'm not sure I would use multiple contexts for what you're doing (if I'm understanding it). I try to avoid multiple contexts whenever possible. I would probably try having a single context but with a plugin connected to OnLoadWebDocument that changed the template with:

                  $modx->resource->set('template') 


                  I'm not sure it would work without setting a $_SESSION variable somewhere to record which domain the user came in on.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 45063
                    • 40 Posts
                    So, the problem is still persists. I have two contexts. Both of the is the same language. The goal is: not to copy the whole context, but only the resources that are different. E.g domain1.com - works as always, domain2.com contains all the content of domain1 (but minor changes) with proper links like domain2/login (the page from 1st context). The thing is, I will have many different contexts, so it will be pretty painful to make one change in all of them.
                      • 45063
                      • 40 Posts
                      So, I've managed to do this by using output modifiers (without contexts). Here is little tutorial (maybe helpful for someone):

                      1. Created a simple gateway plugin which initializing the same context on each domain:

                      if ($modx->context->get('key') == 'mgr') {
                              return;
                      }
                      
                      switch ($_SERVER['HTTP_HOST']) {
                              case 'domain2.com':                
                      		$modx->switchContext('web');
                      		break;
                              case 'domain1.com':                
                                      $modx->switchContext('web');
                                      break;
                              default:
                                      break;
                      }


                      2. Replaced the chunk's call with output modifier. For example: In the resource you placing some chunk:
                      content-content [[$Chunk]] content-content
                      Replace the [[$Chunk]] with
                      [[!++site_url:isequalto=`http://domain1.com/`:then=`[[$Chunk1]]`:else=`[[$Chunk2]]`]]


                      But still, for example I need to replace a single string in the document body. How should I do that? This kind of modifiers works fine, but too slow and it has to be another way to replace each needed word in the whole Modx structure with plugin/snippet and so on. How should I do that?
                      [ed. note: roman.khazizov last edited this post 12 years, 11 months ago.]