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!

edited September 2008 in Vanilla 1.0 Help
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!


  • Options
    SubJunkSubJunk ✭✭
    edited September 2008
    To go back one folder you just use "../", so say you have this setup:


    To reference file1.php from file2.js you would use:


    To reference file1.php from file3.js you would use:


    etc. Does that help? Sorry if it's not helpful I just didn't fully understand what the problem is
  • Options
    yes, there is $Configuration['EXTENSIONS_PATH']but right now I don't see how to use it in the js code, sorry :P
  • Options
    To use PHP in a JavaScript file you can just add the following to the .htaccess file in that folder:
    AddType 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.
  • Options
    edited September 2008
    In js you can use that to get the path to the forum:
    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.*$/) || '';
This discussion has been closed.