CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 HTML List Sitemap in ASP

Print topic Send  topic

Author Message
csierra

Posts: 123
Posted: 12/26/2009, 4:05 PM

Hi there, Ive just made a small class, cSitemap to grab from the classic Menu table we use to generate complex navigations;

The tbMenu fields are: Menu_Id, Menu_Parent_Id, Title, h_ref

And the class code:

  
<%  
Class cSitemap  
  
Private oConn  
Private sList  
Private mList  
Private lId  
Private SQL  
  
Public Function Init  
  
	Set oConn = New clsDBcnx_te_front 'clase de codecharge connection  
	oConn.Open  
  
End Function  
  
  
Public Function List(oSet)  
  
  
	If oSet.BOF and oSet.EOF Then  
	  
	  
	Else  
  
	sList = sList & "<ul>" & vbLf  
  
	Do While Not oSet.EOF  
  
		lId=oSet.Fields("Menu_Id").Value  
  
		If lid<>0 Then  
  
			sList = sList & "<li><a href='" & oSet.Fields("h_ref").Value & "'>" & oSet.Fields("Title").Value & "</a></li>"  
		  
			'Recursive call  
  
			List(SubList(lId))  
  
		Else  
		  
			sList = sList & "<li>" & oSet.Fields("Title").Value & "</li>" & vbLf  
					  
		End If  
  
		oSet.MoveNext   
  
	Loop  
	  
	sList=sList & "</ul>" & vbLf  
  
	End If  
  
	List = sList  
  
End Function  
  
  
  
Public Function SubList(Parent_Id)  
	  
	If IsNull(Parent_Id) Or Not IsNumeric(Parent_Id) Then  
	 SQL = "SELECT * FROM tbMenu WHERE 0=1"  
	Else  
	 SQL = "SELECT * FROM tbMenu WHERE Menu_Parent_Id=" & Parent_Id  
	End If  
	  
	Set SubList = CreateObject("ADODB.Recordset")  
	SubList.Open SQL, oConn.Connection  
  
End Function  
  
End Class  
  
%>  

Just drop it as an includable, then rename the connection accordingly, and you are ready to go; You just use it as this:

  
  
Dim oMap  
  
Set oMap = New cSitemap  
oMap.Init  
Label1.Value=oMap.List(oMap.SubList(0))  

Where label1 should be set as HTML and 0 is my root cat, you could use any Id to show just one category.

Glad to share, comments welcome
_________________
Yes! I Can!!!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.