-
- 3 Posts
I have parts in my snippets that I need to be more like global functions/variables, as they are often reused without change a lot. I have been trying to simply use include or require, but it always causes my pages to just error out and become unusable.
I made a directory in the base directory called 'phpSnips' with 'file.php'. but all directory forms I used failed- such as '../../phpSnips/file.php' and '/phpSnips/file.php'. How do I start the directory from filesystem to be able to include the file, or is there a better way without using another snippet and returning a string to turn into an object somehow.
-
- 247 Posts
MODX_BASE_PATH constant will get you to the www root, you can append whatever path you need to from there. Example:
$file = MODX_BASE_PATH.'/phpSnips/file.php';
Tough to know if this is the best way to go about things without more detail, you may find it's better to handle some of these items via snippets.