Commit new slackware.uk content (with themes).
This commit is contained in:
parent
085631e3d3
commit
e06c1db9cb
54 changed files with 1457 additions and 2572 deletions
44
html/includes/breadcrumbs.php
Normal file
44
html/includes/breadcrumbs.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
# 20200707 bkw: this breadcrumbs() function is loosely based on one
|
||||
# from stackoverflow, but it's been simplified some.
|
||||
function breadcrumbs($sep = ' » ', $home = 'Home') {
|
||||
$pages = explode("/", $_SERVER['REQUEST_URI']);
|
||||
|
||||
# get rid of leading empty element, which will always be
|
||||
# present since we split (exploded) on "/" and the URI
|
||||
# always starts with a /. shift removes & returns the
|
||||
# first (leftmost) element.
|
||||
array_shift($pages);
|
||||
|
||||
# last dir shouldn't be a link, handled separately below.
|
||||
# pop removes & returns the last (rightmost) element.
|
||||
$last = array_pop($pages);
|
||||
if($last == "") {
|
||||
# if we got an empty $last, it means the URL ended
|
||||
# with a /, so get the last non-empty path element
|
||||
$last = array_pop($pages);
|
||||
}
|
||||
|
||||
# links are server-relative, e.g. "/foo/bar" without the
|
||||
# protocol or domain name. Build them in $url.
|
||||
$url = "";
|
||||
|
||||
# home link is always visible and always a link. Doesn't
|
||||
# matter on slackware.uk because the home page doesn't
|
||||
# include breadcrumbs (no use for them there anyway).
|
||||
$result = Array("<a href=\"/\">" . $home . "</a> ");
|
||||
|
||||
# PHP syntax note: $foo[] = "bar" is the same as Perl's
|
||||
# push @foo, "bar".
|
||||
foreach($pages as $dir) {
|
||||
$url = $url . "/" . $dir;
|
||||
$result[] = "<a href=\"" . $url . "\">" . $dir . "</a> ";
|
||||
}
|
||||
|
||||
# add last (current) dir, but not as a link.
|
||||
$result[] = $last;
|
||||
|
||||
# perl: return join($sep, @result);
|
||||
return implode($sep, $result);
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue