thefortrees Posted August 1, 2007 Share Posted August 1, 2007 Hi all - I am trying to implement a dynamic navigation bar. My problem is as follows - All of my scripts are located in various folders, and as you move to different areas of the site, the links to the other areas of the site will change. For example, I am currently at home.php and the nav bar has references to admin/manage_users.php and companies/view_employees.php, etc etc. If I go to manage_users.php, I am now executing a script in the admin folder. The nav bar still has a reference to companies/view_employees.php, which would make this a dead link. There are lots and lots of directories and subdirectories that one can navigate to, so I don't want to have to write code for a nav bar every time. Is there something like $_SERVER['DOCUMENT_ROOT'] that I can use that will help? Link to comment https://forums.phpfreaks.com/topic/62919-solved-dynamic-nav-bar/ Share on other sites More sharing options...
Philip Posted August 1, 2007 Share Posted August 1, 2007 There is: dirname(__FILE__); That shows like /home/user/www/folder1/folder2/ What I did was, even though my PHP files are in a different folder I did: $path = dirname(__FILE__); include $path."/php/admin/head.php"; Hope it helps. Link to comment https://forums.phpfreaks.com/topic/62919-solved-dynamic-nav-bar/#findComment-313265 Share on other sites More sharing options...
soycharliente Posted August 1, 2007 Share Posted August 1, 2007 What's wrong with using $_SERVER['DOCUMENT_ROOT']? Link to comment https://forums.phpfreaks.com/topic/62919-solved-dynamic-nav-bar/#findComment-313303 Share on other sites More sharing options...
Philip Posted August 1, 2007 Share Posted August 1, 2007 Nothing, I was just stating a different way of doing it. I guess I should have put in the word 'also' after "there is" Sorry Link to comment https://forums.phpfreaks.com/topic/62919-solved-dynamic-nav-bar/#findComment-313311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.