Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
File Path troubles!
I'm working on an add-on right now that adds a .js file to the head of each page, and that .js file calls a different php file from the extension folder... the problem is that the file path isn't working on any files nested in folders beyond the top level... is there a config setting or something that calls the absolute path to the extension folder? How can I get it to work in javascript?
Thanks!
0
This discussion has been closed.
Comments
file1.php
folder/file2.js
folder/folder/file3.js
To reference file1.php from file2.js you would use:
href="../file1.php"
To reference file1.php from file3.js you would use:
href="../../file1.php"
etc. Does that help? Sorry if it's not helpful I just didn't fully understand what the problem is
$Configuration['EXTENSIONS_PATH']
but right now I don't see how to use it in the js code, sorry :PAddType application/x-httpd-php .js
All that does is tell the server to treat .js files as .php files, it is mainly used for making .xml files dynamic but can be used for anything.
Then of course you need to include_once the config file so that the .js file knows what the extensions path is.
var pathFinder, root; pathFinder = new PathFinder(); root = pathFinder.getRootPath('script', 'src', 'extensions/MyExtension/myScript.js') || pathFinder.getRootPath('script', 'src', /extensions\/LowCalVanilla\/packer\.php.*$/) || '';
For the path to the extensions folder, you would use that:
var pathFinder, root; pathFinder = new PathFinder(); extensionRoot = pathFinder.getRootPath('script', 'src', 'MyExtension/myScript.js') || pathFinder.getRootPath('script', 'src', /LowCalVanilla\/packer\.php.*$/) || '';