It's okay, I'm very glad you are willing to help. Now:This is how the files are organised:
------
root
/main
- index.php
/second
- index.php
- file.php
- form.php
/system
- leftmenu.php
------
leftmenu.php contains the whole navigation code.
all the other files are sites which have this code there where the navigation is supposed to be:
<?php
include ("../system/leftmenu.php");
?>
This is my goal: When the user is browsing any file in the folder named "second" a submenu would appear. This is what I need the if-statement for.
So if you are browsing main/index.php the navigation would show links to:
- main/index.php
- second/index.php
And if you are browsing any file in "second", eg second/file.php the navigation would show links to:
- main/index.php
- second/index.php
-- second/file.php
-- second/form.php
I tested having this in the leftmenu.php and was browsing main/index.php:
$current_folder = basename(dirname(__FILE__));
print($current_folder);
And it printed "system". Because the leftmenu.php is in the "sytem" folder.
BUT, when I had this code in the leftmenu.php and browsed main/index.php:
$current_url = $_SERVER['PHP_SELF'];
print($current_url);
It printed "/main/index.php".
And having this code in main/index.php itself:
$current_folder = basename(dirname(__FILE__));
print($current_folder);
Printed "main".
So what would solve my problem (I think), is by somehow getting the current folder by using this method:
$current_url = $_SERVER['PHP_SELF'];
What do you think?
/Rade
"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies." - Linus Torvalds