We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4038
    • 21 Posts
    Hello everybody,
    as you might notice, I’m still learning MODx.
    So, I was planning to include some Javascript-files on my MODx site.
    I just used the standard-code in the head-section of the page:
    <!-- Glider -->
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js"></script>
    <script type="text/javascript" src="assets/js/glider.js"></script>
    

    But - it doesn’t work! I find that odd.

    So, I tried to add the code in a chunk - doesn’t work. Add it in a snippet - doesn’t work either. Also, I replaced assets/js... with the real URL (http://www.....de/assets...), to make sure the path is right. But it does not help.
    I read somewhere on the net about a method using a TV with a textarea and the @INHERIT-value. But this doesn’t wok. The input area doesn’t even get displayed.

    My question is, how I can include the Javascript-files successfully. (I tried the search but didn’t find a thread that solves my problem.)

    Edit: Ooops, it seems as if I posted in a totally wrong section. It would be nice if someone could move my thread to the right spot.
      • 25663 MODX Staff
      • 12,272 Posts
      All you need to do is to put them in your template or alternately in a chunk that goes in your template. If you can put this on a publicly accessible site it’d be very much easier to quickly offer assistance. I’ll move this to the general support section.

      When you say it doesn’t work, what’s the error you’re seeing?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 19257
        • 141 Posts
        Hey Ryan! I love the new modx homepage redesign.

        I’m having problems with the same issue. I’m trying to use an image slider plugin that runs with jQuery, but the javascript doesn’t show, which doesn’t let the images load. There’s also a javascript news scroller I’m trying to use but that’s not working either. Both plugins work just fine on my local server when I use the static html pages.

        I’m using a custom made template based on yahoo grids.

        Here’s a copy of the js code

        <script src="[(base_url)]assets/js/jquery-1.3.js" type="text/javascript"></script>
        <script src="[(base_url)]assets/js/s3Slider.js" type="text/javascript"></script>
        <script src="[(base_url)]assets/js/jquery.newsTicker1.2.js" type="text/javascript"></script>


        I had this issue as well with the modxHost original template.
          • 25663 MODX Staff
          • 12,272 Posts
          I don’t know why you’d put the base_url in there. That said, without a link to the problem site on a public server, troubleshooting is going to be a total shot in the dark.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 5340
            • 1,624 Posts
            You should do something like
            <base href="[(base_url)]" />
            <script type="text/javascript" src="/assets/js/jquery-1.3.js"></script>


              • 25663 MODX Staff
              • 12,272 Posts
              Actually the leading "/" in the source may cause issues in some browsers. It probably shouldn’t use the base_url either. Try this:

              <base href="[(site_url)]"></base>
              <script type="text/javascript" src="assets/js/jquery-1.3.js"></script>
              
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 5340
                • 1,624 Posts
                hmm

                I currently do not have issues with the /. Good to know.
                  • 19257
                  • 141 Posts
                  Hmm.. Thanks for the replies and the advice, I’ll give it a try.

                    • 27330
                    • 884 Posts
                    on a side note, while you debug your niffty script, I’ll remind you not to test your scripts in the same browser you are logged into the manager. some scripts used for the manager will break your JS sometimes.
                      • 4038
                      • 21 Posts
                      Actually - that’s the case for me.
                      In any other browser, it’s just perfect.

                      Is there any workaround for that or do I have to live with it?