XF 2.3 Get relative directory of addon

stromb0li

Well-known member
I have a few files I want to reference within my add-on from a view that aren't meant to be directly public to a customer. Is there an easy way to reference them relatively so I don't have to worry about the server path changing?

I.e. if I have /server/folders/that/are/a/mess/src/addons/my/addon/privatefolder/privatefile.xyz; what's the best way to reference the /src/addons/my/addon/privatefolder/privatefile.xyz from my /my/addon/Pub/View/customview.php file.

My current approach is to use __DIR__ and walk back two directories then forward to the file path, but I feel like there is probably a more elegant way?
 
Last edited:
That approach is OK. You can also use \XF::getRootDirectory(), \XF::getSourceDirectory(), or \XF::getAddOnDirectory().
 
Back
Top Bottom