Jump to content

Get file path relative to index.php


DrQuincy
 Share

Recommended Posts

I've got some code that gets run from various locations and the file path is stored in PW (since it varies depending on the environment). I want to be able to store a single setting that works across all environments. The problem is sometimes it's called from init.php and other times from a template. So if my setting is ../data/, this will result in things like:

/MyPWSite/site/templates/../data/
/MyPWSite/site/../data/

I.e. different locations when the data is always in the same place.

What would be ideal is if I can get a file path that is always from the main index.php folder (/MyPWSite/ if you go by the above example) regardless of what point in the application it's called. I've searched for this and can't find it. Is there a variable I can use?

I've not really tested it but in PHP something like this would do it:

dirname($_SERVER['SCRIPT_FILENAME'])

I just wondered if there was already something in the PW API.

Thanks. ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...