Today we are in the process of making a file manager script for our new hosting control panel interface and we want to make breadcrumbs that the user can click on to go back to the path before it. So far they show up like this
Looks alright I suppose. The first three links are static and never change, and the farther off the /home
that the user goes, the more links are added to the breadcrumb. Right now if you were in a directory like we are here aka /home/www/usr/
then the url looks something like this:
/filemanager.php?do=browse&dir=www/usr
Then we explode the $_GET['dir']
between all the items separated by a / and add them into an array. Then we loop through the array and foreach
one we print out an <li>$i</li>
into the breadcrumb area.
The problem now, is how can we make the links for each item in the menu keep its parent folder and / if it has one? When a user clicks on www
in this example, it works because it's the same link as the name, but any child li
needs www/ added to the front, and any other parents as well. A bit stumped here.
Here's the LI adding process we are using:
if(isset($_GET['dir']) && !empty($_GET['dir'])) {
$breadcrumb_list = array();
$breadcrumb_list = explode("/", $_GET['dir']);
echo "<li><a href=\"filemanager?do=browse\">Home</a></li>
";
foreach($breadcrumb_list as $i) {
echo "<li><a href=\"filemanager?do=browse&dir={$i}\">{$i}</a></li>
";
}
}
Any and all help will be appreciated! Thanks guys!