' Liste des sous-dossiers set fc = FSO.GetFolder(server.MapPath(lk2)).subfolders for each f in fc ' Dossier invisible commence par _ if left(f.name,1)<>"_" then temp = temp & "<option class=input value='" & lk2&"/"&f.name & "'>/" _ & up1(replace(f.name,"_"," ")) & "</option>" z = z+1 end if next
' Liste des fichiers du répertoire courant set fc = FSO.GetFolder(server.MapPath(lk2)).files for each f in fc ' Fichier non .asp ou page invisible ? if f.name <> "default.asp" and right(f.name,3)="asp" and left(f.name,1)<>"_" then temp = temp & "<option class=input" ' La page courante ? if lcase(f.name) = page then temp = temp & " SELECTED" temp = temp & " value='" & lk2&"/"&f.name & "'>" _ & up1(replace(replace(f.name,".asp",""),"_"," ")) & "</option>" z=z+1 end if next if z = 0 then temp="" else temp = temp & "</select></td></form>" response.write lk & temp & "</tr></table>" end sub
dolinkbar %>
A appeler de la manière suivante :
<% Set FSO = Server.CreateObject("Scripting.FileSystemObject") URL = lcase(Request.serverVariables("SCRIPT_NAME")) prefix="/asphp2/" ' ou votre début de site LANG="fr" ' un dossier par langue ou vide default = "Accueil"
function up1(txt) ' Capitalise l'initiale if txt <> "" then up1 = Ucase(left(txt,1)) & Lcase(mid(txt,2)) end function %> <HTML><BODY> ... <!-- #include virtual="/_navigation.asp"--> ... </BODY></HTML>
Ou alors en PHP :
_navigation.php
<? // BARRE DE NAVIGATION
function dolinkbar() { global $URL,$prefix,$LANG,$default;
// Lien vers page d'accueil du site $lk = "<table border=0 cellspacing=0 cellpadding=3 style='background:#FFCC99'>"; $lk .= "<tr><td nowrap><A href='".$prefix.$LANG."' target=_top>ASP-PHP.net</A>";
// Nom de la page courante $page = substr($URL,strrpos($URL,"/")+1); // Simplification de l'URL $URL0=str_replace($page,"",$URL); $lk2 = $prefix.$LANG; $URL0=str_replace($lk2,"",$URL0); // Découpage de l'URL au caractère / et liens vers arborescence while(($URL0!="")&&($URL0!="/")) { $k = strpos($URL0,"/",1); $lk2 .= substr($URL0,0,$k); $lk .="<td nowrap> / <A href='".$lk2."' target=_top>"; $lk .=ucfirst(str_replace("_"," ",substr($URL0,1,$k-1)))."</A></td>"; $URL0 = substr($URL0,$k); }
<? $URL = strtolower(getenv("SCRIPT_NAME")); $prefix = "/asphp2/"; // ou votre début de site $LANG = "fr"; // un dossier par langue ou vide $default = "Accueil"; ?> <HTML><BODY> ... <? include("_navigation.php"); ?> ... </BODY></HTML>