I created a custom photo gallery script a while back and now I wish to update it to add some breadcrumbs for easier navigation of the gallery. Everything seems to be going well except for linking to the specific galleries.
The gallery is viewed such as:
page URL: gallery.php?album=/Dir1/Dir2/Dir3/Dir4
It's based of the file directory of the primary Gallery Folder. When album is empty, that is the root folder; name "photos" for example.
I currently have the below php snippet I created to create these breadcrumb links.
The text portion works fine. It would out put the correct breadcrumbs while in the albums. However, the link paths are... backwards, incorrect. Not sure how to explain it. Any ideas on how to fix this minor glitch. It has been frustrating me for the past few hours.
The gallery is viewed such as:
page URL: gallery.php?album=/Dir1/Dir2/Dir3/Dir4
It's based of the file directory of the primary Gallery Folder. When album is empty, that is the root folder; name "photos" for example.
I currently have the below php snippet I created to create these breadcrumb links.
PHP Code:
$path = @$_GET["album"];
if(empty($path)) {
//Echo Nothing as user is in the root directory.
}
else {
$explode = explode('/',$path);
echo "<pre>";
print_r($explode);
$links = '';
for($i=0;$i<count($explode);$i++) {
if(empty($explode[$i])) {
$explode[$i] = "<a href='gallery.php' class='breadcrumb'>Main Gallery</a>";
}
$theLink = '';
for($j=$i;$j<count($explode);$j++) {
if($i==0) {
}else {
$theLink .= '/'.$explode[$j];
}
}
$links .= " / <a href='gallery.php?album=".$theLink."' class='breadcrumb'>".$explode[$i]."</a>";
}
echo $links;
}
Comment