We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23703
    • 180 Posts
    I just found that MODx adds a javascript variable declaration just after the <head>-tag.

    <script type="text/javascript>var MODX_MEDIA_PATH = "media";</script>


    Why does this happen?
      • 32963
      • 1,732 Posts

      This is used by some of the built-in tv scripts

      // set media path for js scripts
      $modx->regClientStartupScript('<script type="text/javascript">var MODX_MEDIA_PATH = "'.(IN_MANAGER_MODE ? 'media':'manager/media').'";</script>');


        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 33114
        • 518 Posts
        and what can be done to remove it legally?
        I never saw this before...today I played with autolink plugin and meta tags - and here it is.
        now I got even two of them smiley http://www.promosound.org/news (and cleaning site cash will remove one)
          http://modx.ru - российская поддержка MODx
          http://newscup.ru - экспериментальный проект
          http://yentsun.com - персональный сайт
          • 32963
          • 1,732 Posts
          Some TV widgets uses this script but you can create a little plugin to remove it if you don’t need it.

          Is it creating a problem on your website? If not why bother to remove it?
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 4369
            • 31 Posts
            Hey there,

            I want to remove it for security reasons.

            How can I do it with a plug-in like you wrote?
              • 32963
              • 1,732 Posts
              Create a plugin and listen to the OnWebPagePrerender. When this event is called you can replace the <script type="text/javascript>var MODX_MEDIA_PATH = "media";</script> found inside $modx->documentOutput.
              for example:

              $js = '<script type="text/javascript>var MODX_MEDIA_PATH = "media";</script>';
              $modx->documentOutput = str_replace($js,'',&$modx->documentOutput);


                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 33372
                • 1,611 Posts
                So which built-in TV scripts use this? I think I’d rather just comment out this code in the parser than add and then remove it. I don’t like anything in my documents that I don’t specifically put there myself...
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 34162
                  • 1 Posts
                  Quote from: xwisdom at Jun 27, 2006, 01:58 PM

                  Create a plugin and listen to the OnWebPagePrerender. When this event is called you can replace the <script type="text/javascript>var MODX_MEDIA_PATH = "media";</script> found inside $modx->documentOutput.
                  for example:

                  $js = '<script type="text/javascript>var MODX_MEDIA_PATH = "media";</script>';
                  $modx->documentOutput = str_replace($js,'',&$modx->documentOutput);

                  I don’t bother about these strange JS-vars (getting used to it from the front-end editing-features wink)
                  But this interception of documentOutput comes in handy! grin
                  Taking this way I could implement an extremely simplified version of Autolink, without the need for an extra db-table, but plain old chunks, loaded into arrays. Thanks for that, xwisdom!

                  @ZAP: just use a multi-file search-tool and let it crawl thru your modx-directory. Would not be too hard to get rid of these vars from their source.
                    • 33372
                    • 1,611 Posts
                    I just commented it out in manager/includes/tmplvars.format.inc.php. But I was a little concerned that this might affect me in unforeseen ways. So that’s why I asked what specifically needs this script so they wouldn’t be unforeseen anymore...
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 34162
                      • 1 Posts
                      Understand your concern! But, since I fiddle around with modx I felt more and more encouraged to just try what I have in mind and see what happens. This, of course, requires a separate testing-environment, for me that’s a local install of modx. And if I screw it up, it doesn’t matter, except that I learned something. laugh