Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

xanburzum

[Resolvido] Menu Tree

Recommended Posts

Este code irá automaticamente criar um menu em árvore. Você só tem que imodificar o início do caminho em que se baseará a sua exibição em árvore.

 

menu.asp

<HTML>
<HEAD>
<TITLE>
BLANK MENU
</TITLE>
<LINK REL=STYLESHEET HREF="./style.css" type="text/css" >
<script LANGUAGE = "JavaScript" src="./script.js"></SCRIPT>

<%

Function Replace(ByVal vstrOrigCharacters, ByVal vstrReplaceCharacters, ByVal vstrString)
	Dim strResult
	Dim intIndex
	Dim intOldIndex
	strResult = ""

	intIndex = 1
	Do

		intOldIndex = intIndex
		intIndex = InStr(intIndex, vstrString, vstrOrigCharacters)
		If (intIndex > 0) Then
			strResult = strResult & Mid(vstrString, intOldIndex, intIndex - intOldIndex)
			strResult = strResult & vstrReplaceCharacters
			intIndex = intIndex + Len(vstrOrigCharacters)
		Else
			strResult = strResult & Mid(vstrString, intOldIndex)
			Exit Do
		End If
	Loop

	Replace = strResult

End Function

Function foundLaunchDirectly(tabFiles, valToFound)

	Dim file
	Dim found 
	Dim intIndex

	found = ""

	For Each file in tabFiles
		intIndex = InStr(1, file.Path, valToFound)	
		if (intIndex > 0) Then
			found = Replace("\","/",file.Path)
			found = LCase(found)
' ********************************************************************************
*******
'			Don't Forget to insert your website address
' ********************************************************************************
*******
			found = Replace("c:/inetpub/wwwroot","http://your_url",found)


			Exit For
		End If
	next
'	***************************************************************************
******
'	Se o arquivo for encontrado, o valor de retorno irá conter o caminho http, caso contrário, será
'   Ser um valor vazio	
'	***************************************************************************
******
	foundLaunchDirectly = found	
End Function

' ********************************************************************************
*******
'Esta função será usada para construir a árvore do menu. É uma função recursiva.
'Os parâmetros são aqueles:
'Path	 - caminho> sobre a utilização do servidor para criar o menu C: \ inetpub \ wwwroot \ ...
'PosX - Posição> em px para o recuo da esquerda
' ********************************************************************************
*******
sub Recurse(Path,posX )

	Dim fso, root, folder, files, folders, file
	Dim name, aff, tmpAff
	Dim launchDirectly 
	Dim tmpRoot, tmpFiles 

' ********************************************************************************
*******
'	Altere o valor da variável launchDirectly com o que você definiu.
'Esta página será aberta diretamente, clicando no submenu
'Não deve conter o conteúdo. Html
' ********************************************************************************
*******
	launchDirectly = "description"

	Set fso = Server.CreateObject("Scripting.FileSystemObject")
		
	Set root = fso.GetFolder(Path)
	Set files = root.files
	Set folders = root.SubFolders
' ********************************************************************************
*******
'	Modificar as linhas acima para tratar os arquivos nos diretórios
' ********************************************************************************
*******
	for Each file in files
		
		name = file.Name
		name = Replace(".html","",name)

		if (name <> launchDirectly) Then
			aff  = Replace("_"," ",name)
			link = Replace("\","/",file.Path)
			link = LCase(link)
' ********************************************************************************
*******
'			Não se esqueça de inserir o endereço do site
' ********************************************************************************
*******
			link = Replace("c:/inetpub/wwwroot","http://your_url",link) 
			Response.Write "<a href='"+link+"' target='screen' onClick='window.focus();'>"+aff+"</a><br>"
		End If

	Next

' ********************************************************************************
*******
'	Modificar as linhas acima para tratar os diretórios
' ********************************************************************************
*******
	for Each folder in folders
		name = folder.Name
		aff = Replace ("_"," ",name)
		Response.Write "<!-- BEGIN MENU -->"
		Set tmpRoot = fso.GetFolder(folder.Path)
		Set tmpFiles = tmpRoot.files
		tmpAff = foundLaunchDirectly(tmpFiles, launchDirectly)
		if ( tmpAff <> "") Then
			Response.Write "<a href='"+tmpAff+"' target='screen' onClick=swapTree('div"+name+"');>"
		else
			Response.Write "<a href='#' target='' onClick=swapTree('div"+name+"');>"	
		End If
		Response.Write "<img name='img_div"+name+"' src='./droite.gif' border=0 align='absmiddle' hspace='1'><b>"+aff+"</b></a><br>"

			Response.Write " <div id='div"+name+"' " 
		Response.Write " style='z-index:3;display: none; margin-left:"
		Response.Write posX
		Response.Write "px' align='left'>"

		Recurse folder.Path, (posX+5)
		cpt = cpt + 1
		Response.Write "</div>"
		Response.Write "<!-- END MENU -->"

	Next

End Sub

%>

</HEAD>
<BODY BGCOLOR="#D0EAFC" >

<!--
********************************************************************************
************************
********************************************************************************
************************
-->
<%
' ********************************************************************************
*******
' O primeiro parâmetro deve ser alterado com o diretório que deseja analisar
' ********************************************************************************
*******
Recurse "C:\InetPub\wwwroot\dbWebsite\menu\"+Request.QueryString("menuName")+"\en", 15

%>
<!--
********************************************************************************
************************
********************************************************************************
************************
-->

</BODY>
</HTML>

script.js

function swapTree(menuDiv)
{
   window.focus();
   d=eval("document.all."+menuDiv);
   i=eval("document.all.img_"+menuDiv);
   if (d.style.display=="none")
   {
	  d.style.display="block";
	  i.src='./bas.gif';
   }
   else
   {
	  d.style.display="none";
	  i.src='./droite.gif';
   }

}

CSS

TABLE, BODY, FORM, INPUT
{
color=#000055;
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
margin-left=0pt;
margin-right=0pt;
margin-top=0pt;
}
TD.date
{
color=#550000;
font-size:9px;

}
TD.summarize
{
color=#000055;
font-size:9px;
text-decoration:italic;
}
P.title
{
font-size:12px;
}
LI{
line-height:14px;
}
a{
line-height:14px;
color:#E22E3C;
text-decoration:none;
}
a:hover{
font-weight:bold;
text-decoration:underline;
}
SELECT{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#000000;
}
INPUT.text{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
line-height:12px;
color:#000000;
}
INPUT.submit{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:12px;
color:#666666;
}
TEXTAREA{
font-size:12px;
font-family:Verdana, Arial, Helvetica, sans-serif;
line-height:15px;
color:#000000;
}
.pathbig{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:700;
line-height:13px;
color:#E22E3C;
text-decoration:none;
}
.pathsmall{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:400;
line-height:13px;
color:#000000;
text-decoration:none;
}
.verdana{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:normal;
line-height:14px;
color:#000000;
text-decoration:none;
}
.tib{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:14px;
color:#000000;
text-decoration:none;
}
.tik{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:400;
font-style:italic;
line-height:14px;
color:#000000;
text-decoration:none;
}

.tibred{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:14px;
color:#E22E3C;
text-decoration:none;
}
.tiblue{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:18px;
color:#000055;
text-decoration:none;
}
.tistate{
font-size:13px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:18px;
color:#666666;
text-decoration:none;
}
.tigrey{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:500;
line-height:14px;
color:#999999;
text-decoration:none;
}
.txs{
font-size:6px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:400;
line-height:8px;
color:#000000;
text-decoration:none;
}
.txb{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:regular;
line-height:14px;
color:#000000;
text-decoration:none;
}
.txred{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:regular;
line-height:14px;
color:#E22E3C;
text-decoration:none;
}
.txblue{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:100;
line-height:14px;
color:#000055;
text-decoration:none;
}
.txlightblue{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:100;
line-height:14px;
color:#9197AE;
text-decoration:none;
}

txgrey:link { color:#7A7A7A; text-decoration:none; }
txgrey:visited { color:#686868; text-decoration:none; }
txgrey:active { color:#000000; text-decoration:none; }

.txgrey{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:normal;
line-height:14px;
color:#666666;
text-decoration:none;
}
.txbluel{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:normal;
line-height:13px;
color:#000055;
text-decoration:none;
}
.txstate{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:18px;
color:#335273;
text-decoration:none;
}
.txstateb{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:18px;
color:#23305D;
text-decoration:none;
}
.txstateg{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:600;
line-height:18px;
color:#7A7A7A;
text-decoration:none;
}
.bigtxb{
font-size:11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:100;
line-height:18px;
color:#000000;
text-decoration:none;
}
.smallblue{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:100;
line-height:14px;
color:#000055;
text-decoration:none;
}

.copyright{
font-size:10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight:100;
line-height:14px;
text-decoration:none;
}

#divCopyright {
visibility:visible;
}

#menumarket {
line-height:5px;
}
#menusales {
line-height:10px;
}
#divContent {
position:absolute;
top:85px;
left:171px;
width:358px;
height:1px;
visibility:visible;
z-index:6
}
#divMenu {
position:absolute;
top:85px;
left:31px;
width:325px;
height:1px;
visibility:visible;
z-index:5
}
#divNews{
position:absolute;
top:85px;
left:529px;
width:231px;
height:1px;
visibility:visible;
z-index:6
}
#divLogo {
position:absolute;
top:10px;
left:14px;
width:131px;
height:25px;
visibility:visible;
z-index:2
}

#secret {
visibility:hidden;
}

#divMenutop {
position:absolute;
top:0px;
left:171px;
width:600px;
height:1px;
visibility:visible;
background-color:#DFF0F0;
z-index:3
}
#divWatermark {
position:absolute;
top:23px;
left:13px;
width:310px;
height:376px;
visibility:visible;
}
#divPattern {
position:absolute;
top:85px;
left:31px;
width:740px;
height:1px;
visibility:visible;
z-index:4
}
#divFooter {
position:absolute;
top:68px;
left:171px;
width:600px;
height:21px;
background-color:#83A7C2;
visibility:visible;
z-index:7
}


#divPopup {
position:absolute;
top:25px;
left:293px;
width:146px;
height:46px;
background-color:#83A7C2;
visibility:hidden;
z-index:9
}

#divPopupProduct {
position:absolute;
top:31px;
left:420px;
width:146px;
height:16px;
background-color:#83A7C2;
visibility:hidden;
z-index:9
}

#divPopupSupport {
position:absolute;
top:31px;
left:603px;
width:76px;
height:23px;
background-color:#83A7C2;
visibility:hidden;
z-index:9
}

#divPopupSearch {
position:absolute;
top:31px;
left:696px;
width:76px;
height:16px;
background-color:#83A7C2;
visibility:hidden;
z-index:9
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.