WayneSmallman
Member
Posted 3 years ago #
Hi guys!
I've developed a navigation system, which I want to use within WordPress. The system itself is a class file. I'm using the "require" function to pull in the file and instantiating the class, then I'm calling the methods to build the navigation.
However, I can't find the correct path for my folder "library" which is on the root.
I've tried everything I know but I can't get at the root from within the "header.php" file.
Any ideas?
WayneSmallman
Member
Posted 3 years ago #
Any takers? I could really do with some help here.
More details on the problem would be helpful.
I assume when you say require, you are referring to...
require('myfile.php'); etc....
Could try $_SERVER['DOCUMENT_ROOT'] ...
Print or Echo out your problem paths, and see what comes up...
From: http://uk3.php.net/function.require
If you use relativ paths in a php script (file A) that can be required by another php script (file B), be aware that the relativ paths in file A will be relativ to the directory, where file B is stored.
You can use the following syntax in file A, to be sure that the paths are relativ to the directory of file A:
<?
require(dirname(__FILE__)."/path/relative/file_to_include.php");
?>
and:
if you want to include files with an absolut path reference, you can use:
require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");
this way you can organize your files in subdirectories trees.
Hope that helps?
WayneSmallman
Member
Posted 2 years ago #
@t31os: "I'm using the 'require' function" That's self explanatory. There is only the one such function in PHP, as far as I am aware.
What I wrote is all of the detail there is to provide.
I've tried all of the standard global variables and none worked.
In the end, the only method that would / will work is: require (ABSPATH . '/library/classes/class.page.php');