Dopo diverse ore di ricerca, ho trovato uno scriptino di Breadcrumbs che fa al caso mio.
(per chi non lo sapesse, i breadcrumbs sono i link di navigazione tipo "Home > Dir > File corrente").
Me ne serviva uno che ricostruisse il tutto a partire dall'url, e non da $PATH, dato che uso mod_rewrite.
qui ho trovato il seguente codice, che funge a meraviglia:
Codice PHP:
function coma_print_breadcrumb($depth = 0, $separator = " » ") {
# generates a breadcrumb from the URL - Peter rules November 2000
$requested = getenv('REQUEST_URI');
$crumb = split("/",$requested);
# if no filename requested filename is index.php
if (!strstr ($requested,".php")) $crumb[sizeof($crumb)-1] = "index.php";
# loop through sections
for ($i = $depth; $i <= (sizeof($crumb)-1); $i++) {
# get wording from array
$wording = $coma_breadcrumb[$crumb[$i]];
# if no wording was definded use the name of the file
if ($wording == "") {
$part = explode(".",$crumb[$i]);
$wording = $part[0];
}
# define wording root directory
if ($i==0) $wording = "home";
# if not the first section print seperator
print ($i==$depth)? "":$separator;
# if not last one print href
if ($i < (sizeof($crumb)-1) AND !($crumb[$i+1]=="index.php")) {
print "" . $wording . "";
} else { # print no href
print $wording;
}
}
}
coma_print_breadcrumb();
Va che è un piacere: solo che scrive il tutto come testo e basta, mentre io vorrei aggiungere dei link:
la riga da cambiare è questa:
print "" . $wording . "";
l'ho cambiata così:
print "<a href=\"" .$wording. "\">" . $wording . "</a>";
Soltanto che non so cosa mettere al posto del primo $wording.
Quel che vorrei ottenere è un link per ogni cartella, alla cartella medesima.
Mi date qualche indicazione, perfavore?