Barre de Navigation |
Celle qui est en haut de page !... |
|
Voir le script PHP ?

| _navigation.asp |  |  | |
| <% ' BARRE DE NAVIGATION
sub dolinkbar() dim page,url0,lk,lk2,fc,f,temp,z
' Lien vers page d'accueil du site lk = "<table border=0 cellspacing=0 cellpadding=3 class=bgnav>" _ & "<tr><td nowrap><A target=_top href='" & prefix & LANG & "'>ASP-PHP.net</A>"
' Nom de la page courante page = mid(url,instrrev(URL,"/")+1)
' Simplification de l'URL URL0=replace(URL,page,"") lk2 = prefix & LANG if LANG="" then lk2=left(lk2,len(lk2)-1) URL0=replace(URL0,lk2,"")
' Découpage de l'URL au caractère / et liens vers arborescence while URL0<>"/" k = instr(2,URL0,"/") lk2 = lk2 & left(URL0,k-1) lk = lk & "<td nowrap> / <A href='" & lk2 & "' target=_top>" _ & up1(replace(mid(URL0,2,k-2),"_"," ")) & "</A></td>" URL0 = mid(URL0,k) wend
' Liste déroulante à déclenchement automatique temp = "<td nowrap> / </td><form name='navig'><td>" _ & "<select class=input name=""liste"" onchange=" & chr(34) _ & "javascript:top.location.replace (navig.liste.options[navig.liste.selectedIndex].value)" _ & chr(34) & "><option class=input value='default.asp'>" & default & "</option>"
' 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); }
// Liste déroulante à déclenchement automatique $temp = "<td nowrap> / </td><form name='navig'><td>"; $temp.= "<select class=input name='liste' onchange=\""; $temp.= "javascript:top.location.replace(navig.liste.options[navig.liste.selectedIndex].value)"; $temp.= "\"><option class=input value='index.php'>".$default."</option>";
$dir = opendir("."); while ($f = readdir($dir)) { // Liste des sous-dossiers if(is_dir($f)&&($f!=".")&&($f!="..")) // Dossier invisible commence par _ if(substr($f,0,1)!="_") { $temp.="<option class=input value='".$lk2."/".$f."'>/"; $temp.=ucfirst(str_replace("_"," ",$f))."</option>"; $z+=1; } // Liste des fichiers du répertoire courant if(is_file($f)) // Fichier non .php ou page invisible ? if((substr($f,0,1)!="_")&&(strpos($f,".php")>0)&&($f!="index.php")) { $temp2.="<option class=input"; // La page courante ? if(strtolower($f)==$page) $temp2.=" SELECTED"; $temp2.=" value='".$lk2."/".$f."'>"; $temp2.=ucfirst(str_replace(".php","",str_replace("_"," ",$f)))."</option>"; $z+=1; } }
closedir($dir);
if($z==0) $temp = ""; else $temp.=$temp2."</select></td></form>";
echo $lk.$temp."</tr></table>"; }
dolinkbar(); ?> |
A appeler de la manière suivante :
<? $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>
|
Enjoy !
Didier le
03/06/2003 (63 955 hits) |
|
|