I have a few .js javascript files that I need to add into my sytem. They are used to display div's on my page with a slide-down action when the link is clicked. I am wondering what the best was is, to add a few .js file to the system. I will need to reference the files in my code in various places. Would just creating a folder under my site, and adding them work? Or would matrix even recognize these files?
Just upload them as file assets into a web accessible location (like the directory you suggested). Then, reference them using ./?a=xxx notation inside content.
If you want to put them in your design instead, so they are available on every page, upload them as associated files on the design details screen and reference them using mysource_files/name.js notation in the design parse file.
Make the JS file assets Live and give them Public Read access. Matrix will then get Apache to serve the files directly.
I was able to add the .js files without a problem. What I am adding is the script.aculo.us javascript files, so that I can easily add javascript functions to my site.
It seems that there is still a problem with getting the files to work. I add all of the .js files under my design, made them live, and gave them public access. I then linked the files with mysource_files/ in my parse file. When viewing my page, the source gives the full path to my .js files, and these files are able to be viewed even which logged out of the system (public user). But when trying to link some of the java functions in a page to the files it is not working. It is something within matrix that is not right, because I tried linking to some external .js files on another site and the functionality then worked on my matrix site. But when I try to go back and link to my .js files that I have added to matrix, the funtions no longer work.
Is this because I should be adding the .js files under my design customization? It seems since the full path of my .js files are printed in the parse file, that everything should be working, but it is not…
It sounds like the URLs look fine, and it wont even be Matrix serving those JS files any more, so I don't know exactly what the problem is or what Matrix could be doing.
Could it be that some of the .js files reference other .js files and assume they are in the same directory as the current .js file (which they wont be in Matrix without tweaking the config)? Can you check to see if you are getting any 404's in Apache for .js files?
I am pretty sure this is the problem. There are 2 files that are linked in the parse file, and some others that those are pointing to. Is there any way in matrix to get all of those files into one directory? Or would this involve manually doing it in apache? There must be some way...
Apache logs getting this error:
[Tue Jan 02 11:08:34 2007] [error] [client 10.50.3.23] File does not exist: /home/websites/mysource_matrix/data/public/assets/file/1093/builder.js, referer: http://10.50.3.28/contact/
[Tue Jan 02 11:08:34 2007] [error] [client 10.50.3.23] File does not exist: /home/websites/mysource_matrix/data/public/assets/file/1093/effects.js, referer: http://10.50.3.28/contact/
[Tue Jan 02 11:08:34 2007] [error] [client 10.50.3.23] File does not exist: /home/websites/mysource_matrix/data/public/assets/file/1093/dragdrop.js, referer: http://10.50.3.28/contact/
[Tue Jan 02 11:08:34 2007] [error] [client 10.50.3.23] File does not exist: /home/websites/mysource_matrix/data/public/assets/file/1093/controls.js, referer: http://10.50.3.28/contact/
[Tue Jan 02 11:08:34 2007] [error] [client 10.50.3.23] File does not exist: /home/websites/mysource_matrix/data/public/assets/file/1093/slider.js, referer: http://10.50.3.28/contact/
Yes, you can stop Matrix rewriting the URL to use Apache. On the Details screen of each file, you need to uncheck the "Allow unrestricted access" checkbox. This tells Matrix that it can never let Apache serve the file without going through Matrix first.
Then, make sure all the .js files are on the same level in the asset map so that the relative URLs inside the .js files work correctly.
If that doesn't work, you'll probably have to move the files out of the design and into a directory structure under your site (still not allowing unrestricted access). You can still reference them in the design, but you'd use hard-coded URLs.