Hi folks,
I've wandered into a brick wall into a subroutine in a script I'm creating.
Hokay, what I'm doing is parsing the request_uri and I want to create a clickable location bar, like on go.com.
So if my request_uri was say /subdir1/subdir2/subdir3/, I would want my navbar to look like this:
You are here --> Home > Subdir > Subdir2 > Subdir3
My code so far looks like this:
my @dirs = split("/",$ENV{REQUEST_URI});
splice(@dirs,0,3); # Ignore this, I'm just removing some extra dirs.
if (!$dirs[0]) { # If there's no first dir, I'm
$location = "Home"; # at home, so I want an unlinked "Home"
}
elsif (!$dirs[1]) { # If there's nothing after the first one
$location = ucfirst($dirs[0]); # I'm there, so I don't need a link.
}
else { # Otherwise, the first part is a linked "Home"
$location = "<a href=\"/sites/test/home/\">Home</a>";
foreach $dir (@dirs) {
# And now I'm in trouble...
# I need to set up some kind of loop and a count here to parse the rest of
# the array and create the links accordingly, excluding the last one,
# which doesn't need to be linked. Last one would be $#dirs???
}
}
}
Sorry if I'm not being clear enough, please ask me if there's anything I can clarify...
Thanks,
adam
[This message has been edited by dahamsta (edited May 20, 1999).]
I've wandered into a brick wall into a subroutine in a script I'm creating.
Hokay, what I'm doing is parsing the request_uri and I want to create a clickable location bar, like on go.com.
So if my request_uri was say /subdir1/subdir2/subdir3/, I would want my navbar to look like this:
You are here --> Home > Subdir > Subdir2 > Subdir3
My code so far looks like this:
Code:
sub getlocation { my @dirs = split("/",$ENV{REQUEST_URI});
splice(@dirs,0,3); # Ignore this, I'm just removing some extra dirs.
if (!$dirs[0]) { # If there's no first dir, I'm
$location = "Home"; # at home, so I want an unlinked "Home"
}
elsif (!$dirs[1]) { # If there's nothing after the first one
$location = ucfirst($dirs[0]); # I'm there, so I don't need a link.
}
else { # Otherwise, the first part is a linked "Home"
$location = "<a href=\"/sites/test/home/\">Home</a>";
foreach $dir (@dirs) {
# And now I'm in trouble...
# I need to set up some kind of loop and a count here to parse the rest of
# the array and create the links accordingly, excluding the last one,
# which doesn't need to be linked. Last one would be $#dirs???
}
}
}
Sorry if I'm not being clear enough, please ask me if there's anything I can clarify...
Thanks,
adam
[This message has been edited by dahamsta (edited May 20, 1999).]

