Forum Moderators: coopster
thanks
you have a rootdir:
e.g. /wwwroot/
news are in
/wwwroot/news/news.php
events are in
/wwwroot/events/events.php
and refs are in
/wwwroot/refs/refs/refs.php
and your navigation/menu file is in
/wwwroot/cms/menu.inc
so define in news and events:
e.g.:
define ("PATH_BASE","../");
and in refs.php
define ("PATH_BASE","../../");
now you can include your menu file like
require (PATH_BASE."cms/menu.inc");
i hope, i've understood what you mean
PHP will only include files if they are located in one of the directories specified in 'include_path' in the php.ini file. Usually, the first path specified is '.', which translates as the current directory. This is why you can only include files in the same directory as your calling file, and any attempts to build a path to a file in a different directory fail.
If you are using an ISP's PHP implementation, they have probably specified an include directory already. To find out, make a tiny PHP file with this code in it:
<?php phpinfo();?>
Save the file as phpinfo.php and FTP it up to your domain. Run the page in a browser:
http:// yourdomain / phpinfo.php
This will give you the specs for your PHP implementation. Hit ctrl+F in your browser to open up a search box, and search for 'include_path'. This will give you the allowed include path for your site. You should see 'public_html' in there, and any further directories are subdirectories of your site.
If there's nothing listed, or if for some reason you need to specify another path, you can add a line to your .htaccess file (assuming you haven't got access to php.ini) to add new paths. If you need to know how to do this then let me know.
1. get the server root path by running this command on a page:
<?php echo $_SERVER["DOCUMENT_ROOT"]?>
2. Download your .htaccess file, than add this line to it:
php_value include_path ".:/usr/www/your_main_site_folder/includes"
Change the path to what you got from the document root information.
Make sure you put a linebreak after this addition, then upload the .htaccess file in ASCII (text) mode.
Now all your includes will look for this path no matter where they occur in your site.
OK! Here's a couple:
Accessing PHP includes folder in root dir from 2+ levels deep [webmasterworld.com]
Some tips and tricks in this thread [webmasterworld.com] and it's related links may help too.