We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7584
    • 15 Posts
    Just a quick question, why does the relative paths in output.class.inc.php call the javascript libraries without a forward slash?

    <!-- Start QuickEdit headers -->
    <script type="text/javascript" src="{$manager_path}media/script/scriptaculous/prototype.js"></script>
    <script type="text/javascript" src="{$qe_path}/javascript/Cookie.js"></script>
    <script type="text/javascript" src="{$qe_path}/javascript/Drag.js"></script>
    <script type="text/javascript" src="{$qe_path}/javascript/moo.fx.js"></script>
    <script type="text/javascript" src="{$qe_path}/javascript/QuickEdit.js"></script>
    <link type="text/css" rel="stylesheet" href="/{$qe_path}/styles/toolbar.css" />
    <!-- End QuickEdit headers -->


    I’ve looked through the manager client and in config.inc.php to see if there was some site_url setting, e.g. maybe somewhere I specified "domain.com" instead of "domain.com/" but couldn’t find it. So, I suppose $qe_path only relates to the path to the javascript libraries??

    I’m posting because when I’m on a top-level page, the QuickEdit functions load fine. As soon as I traverse down a level, the UI element of QuickEdit blows out the page a bit because its trying to reference "path/to/file.js" which doesn’t exist at that level, instead "/path/to/file.js" which does.

    The odd thing is the toolbar.css file correctly includes a forward slash, whereas the others do not.

    Just curious,

    Geoffrey
      • 5727
      • 160 Posts
      Quote from: djhomeless at Mar 24, 2007, 10:59 PM

      Just a quick question, why does the relative paths in output.class.inc.php call the javascript libraries without a forward slash?

      If we put a forward slash, the path is taken from the root of the server. It’s no longer relative. What if I installed MODx in a sub-folder? I’m guessing that you configured MODx to use friendly URLs, because, otherwise, all your files would be served from the one and only index.php. Your problem has been documented and you simply need to add a <base href="http://www.mysite.com/"> tag in the head of your templates and everything should work A1.
        Olivier Deland
        Montreal, Canada - Web Developer
        • 7584
        • 15 Posts
        Quote from: ConseilsWeb at Mar 25, 2007, 04:19 AM

        Quote from: djhomeless at Mar 24, 2007, 10:59 PM

        Just a quick question, why does the relative paths in output.class.inc.php call the javascript libraries without a forward slash?

        What if I installed MODx in a sub-folder? I’m guessing that you configured MODx to use friendly URLs, because, otherwise, all your files would be served from the one and only index.php. Your problem has been documented and you simply need to add a <base href="http://www.mysite.com/"> tag in the head of your templates and everything should work A1.

        That makes sense. Though, just thinking out loud, I wonder why this sort of thing is not handled by some sort of site config as I would assume that most installations would be in the root as opposed to a sub folder?

        Anyway, thanks for the tip. A lot cleaner than introducing a slash in output.class.inc.php.

        Geoffrey
          • 34162
          • 1 Posts
          Ive also spoken about this problem here: http://modxcms.com/forums/index.php/topic,13249.msg87265.html

          The standard answer seems to be to add <base href="[(site_url)]" /> into the head.

          Using this method causes other problems: "Anchor links in a page"

          An example:
          I have a Question & Answers page whereby questions are listed at the top of the page and when clicked they take you to the Anchor in the same page.

          The output without <base href="[(site_url)]" /> :
          DOMAINNAME.com/FILE.php#ANCHOR

          The output with <base href="[(site_url)]" />:
          DOMAINNAME.com/#ANCHOR

          There are workarounds such as: "[~ID~]#ANCHOR" or creating individual snippets such as found here: http://modxcms.com/forums/index.php/topic,6228.msg43953.html

          Both of the solutions arent user friendly.

          Getting back to the main issue:

          I have taken out the "{$qe_path}/javascript/" and replaced it with "/assets/modules/quick_edit/javascript/" and it works when FURL’s etc are activated. But there is a drawback, when im working localy and dont have FURL’s activated it doesnt work. So now ive got 2 documents one for local work and one for using on the live site.

          So if there is a better workaround / dynamic workaround other than using <base href="[(site_url)]" /> or my solution then that would be great.
            • 5727
            • 160 Posts
            Quote from: gsx750r at Mar 25, 2007, 08:50 PM


            Getting back to the main issue:

            I have taken out the "{$qe_path}/javascript/" and replaced it with "/assets/modules/quick_edit/javascript/" and it works when FURL’s etc are activated. But there is a drawback, when im working localy and dont have FURL’s activated it doesnt work. So now ive got 2 documents one for local work and one for using on the live site.

            So if there is a better workaround / dynamic workaround other than using <base href="[(site_url)]" /> or my solution then that would be great.

            I think that instead of replacing it with /assets/modules/quick_edit/javascript/, which will only work if you installed modx in the root directory, you could simply add $modx->config[’base_url’] before the $qe_path. This would make it work in every and all situations.

            so, to sum it up: open file "assets/modules/quick_edit/output.class.inc.php" and go to line 230 and replace it with this:
            <!-- Start QuickEdit headers -->
            <script type="text/javascript" src="{$manager_path}media/script/scriptaculous/prototype.js"></script>
            <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/Cookie.js"></script>
            <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/Drag.js"></script>
            <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/moo.fx.js"></script>
            <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/QuickEdit.js"></script>
            <link type="text/css" rel="stylesheet" href="{$modx->config['base_url']}{$qe_path}/styles/toolbar.css" />
            <!-- End QuickEdit headers -->
            
              Olivier Deland
              Montreal, Canada - Web Developer
              • 7584
              • 15 Posts
              Quote from: ConseilsWeb at Mar 25, 2007, 10:57 PM

              so, to sum it up: open file "assets/modules/quick_edit/output.class.inc.php" and go to line 230 and replace it with this:
              <!-- Start QuickEdit headers -->
              <script type="text/javascript" src="{$manager_path}media/script/scriptaculous/prototype.js"></script>
              <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/Cookie.js"></script>
              <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/Drag.js"></script>
              <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/moo.fx.js"></script>
              <script type="text/javascript" src="{$modx->config['base_url']}{$qe_path}/javascript/QuickEdit.js"></script>
              <link type="text/css" rel="stylesheet" href="{$modx->config['base_url']}{$qe_path}/styles/toolbar.css" />
              <!-- End QuickEdit headers -->
              


              I’ve taken a much more lo-fi approach to this, though I’m not sure what the downside would be:
              <!-- Start QuickEdit headers -->
              <script type="text/javascript" src="{$manager_path}/media/script/scriptaculous/prototype.js"></script>
              <script type="text/javascript" src="/{$qe_path}/javascript/Cookie.js"></script>
              <script type="text/javascript" src="/{$qe_path}/javascript/Drag.js"></script>
              <script type="text/javascript" src="/{$qe_path}/javascript/moo.fx.js"></script>
              <script type="text/javascript" src="/{$qe_path}/javascript/QuickEdit.js"></script>
              <link type="text/css" rel="stylesheet" href="/{$qe_path}/styles/toolbar.css" />
              <!-- End QuickEdit headers -->
              


              To be honest, I think both accomplish the same goal, though obviously the above only works in the case where you have installed modx in the root.

              I would think though that your suggestion is really a better fix, maybe something to raise as a feature request?

              Geoffrey
              • If you add a base href to your template head, all problems should be solved. The base_url has been removed for the next release. smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 5727
                  • 160 Posts
                  Quote from: rthrash at Mar 26, 2007, 01:56 PM

                  If you add a base href to your template head, all problems should be solved. The base_url has been removed for the next release. smiley


                  I thought so too, but it seems that the base href solution brings another problem as mentionned by gsx750r:
                  The output without <base href="[(site_url)]" /> :
                  DOMAINNAME.com/FILE.php#ANCHOR

                  The output with <base href="[(site_url)]" />:
                  DOMAINNAME.com/#ANCHOR

                  I’m thinking this could be a bad implementation from our favorite browsers, but after reading through the w3c recommendations it doesn’t really say anything about anchors and base href.

                  Why drop the base_url config anyways?
                    Olivier Deland
                    Montreal, Canada - Web Developer