We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6902
    • 126 Posts
    After much searching, I’m unable to find definitive answers to a couple of questions...



    1) Is there a way to specify a context-specific setting with [[++____]] ?

    Example:
    I make all my templates with a property that is a path to the template folder, i.e., the template property "tpl" becomes the placeholder [[+tpl]] ... this is set to something like: [[++base_url]]assets/templates/mytemplate/
    This works great within the web context, but breaks from the dev context which is on a different domain. Is there some way to specify that I want the base_url (or maybe the site_url) of a specific context within the tag?Maybe something like [[++base_url:ctxt=`web`]] so that, even though I am in the dev context, I can still have it pointing to the right template folder on the web context’s domain?



    2) I am having trouble linking between contexts:

    Given 2 contexts with resources:

    Web:
    my page (1)
    another page (2)

    Dev:
    yet another page (3)
    in development (4)

    I have set up my dev and web domains with specific base_url, site_url, http_host, site_name, & site_start. Each is on a separate domain. I can get to all resources and pages load just fine. Here’s where it’s weird. I can link from web to dev just fine, i.e., resource 1 contains [[~3]] which returns a proper link to resource 3. However, I can’t link from dev to web, i.e., resource 3 contains [[~1]] which just returns an empty string.

    Is there something I’m missing?



    3) Parsing tags within a placeholder called from a snippet.

    Given the example tpl property above ([[++base_url]]assets/templates/mytemplate/) which works just fine when being referenced in a template or elsewhere, if I use $modx->getPlaceholder(’tpl’) in a snippet, any tags are not parsed/processed and it ends up breaking the output. Is there a way within a snippet to have modx parse a string for tags?



    For all of this I’m running Revo 2.0.6-pl

    Thanks in advance for any insight!

    laugh

      • 9207 ☆ A M B ☆
      • 2,475 Posts
      That’s a really interesting idea. There are a few other threads going around right now re setting up dev/prod variants of a site. I know one of the doc pages showed how to use contexts for this separation.

      I wonder if it might be cleaner to use a plugin to monitor the active context and use that to modify the system settings as req’d...

      If there isn’t a viable way to handle this, it might be a worthy feature request over at bugs.modx.com...
        • 22303 MODX Staff
        • 10,725 Posts
        1. You should never need to access a setting from another context.
        2. You always need to set your site_url and base_url for every context when using multiple-contexts. I think this is the only problem you are having, if I understand correctly; set site_url and base_url in the web context.
        3. You should never need to manually parse this data; just output the tags and they will get parsed.
          • 6902
          • 126 Posts
          1) But, in this case, doing so would make production 1000% easier. I want to use the same template, in the same folder, in the same domain, from different contexts. If I can’t get a context’s base_url or site_url, then I will have to use fully-qualified links instead of relative links ... which isn’t horrible, but it’s certainly not ideal.

          Actually, how is what I’m wanting to do any different than the [[~#]] link tag accessing a context’s path information to build links? Data from one context is being accessed from within another... the link tag still has to go to the other context to grab the site_url, base_url, etc to build the correct path to the page that it’s linking to.

          2) site_url and base_url are set for all contexts. Links from web to dev work fine. Links from dev to web don’t.

          3) but the tags aren’t getting parsed.

          Template Property:
          ’tpl’ = [[++base_url]]assets/templates/mytemplate/

          Snippet:
          ’load_css’ = $modx->regClientCss($modx->getPlaceholder(’tpl’).’mystylesheet.css’);
          (I tried moving the getPlaceholder call to a separate line, but that had no affect.)

          Template:
          ... [[!load_css]] ...

          Final Output:
          ... [[++base_url]]assets/templates/mytemplate/mystylesheet.css ...
            • 28215
            • 4,149 Posts
            Why not just make a [[++main_site_url]] System Setting and use that?
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 6902
              • 126 Posts
              That worked great, actually. Thanks!
                • 37261 ☆ A M B ☆
                • 113 Posts
                I know this is an old thread but I'm having the same issue in a multi-context site in Revo 2.2.7 and have spent hours trying to figure it out.

                site1.com with site_start of resource 1 and site2.com with site_start of resource 2 will not cross link to each other. [[~1? &scheme=`full`]] on site2.com incorrectly links back to site2.com when it should link to site1.com, [[~2? &scheme=`full`]] on site1.com incorrectly links back to site1.com. Both sites have the base_url and site_url set in their respective context settings. Why is &scheme=`full` not getting the site_url from the context that contains the resource? I have allow_forward_across_contexts turned on so that I can use symlinks to share the same content on some pages if that matters.

                I finally found this thread and set a site1_url and site2_url system setting to link back and forth but this is not ideal.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Is this new in 2.2.7 for you? If so, it would be good to open a new topic or an issue in the tracker.

                  Also, you shouldn't need to use scheme; cross-context links should actually automatically use the full scheme.

                  As for why it's not working, that is more difficult to ascertain. I will do some testing on it myself and see if I can reproduce...
                    • 37261 ☆ A M B ☆
                    • 113 Posts
                    Not sure if it is a new issue or operator-error. I tried it on another multi-context installation with the same result. I did find this, and appended my notes, in the tracker which appears to be the same issue: http://tracker.modx.com/issues/9769 [ed. note: pyrographics last edited this post 13 years, 4 months ago.]