Created
April 9, 2013 16:01
-
-
Save saga/5346957 to your computer and use it in GitHub Desktop.
Getting subject nodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub SubjectList() | |
Dim TreeMgr As TreeManager | |
Dim SubjRoot As SubjectNode | |
Dim ChildNode As SubjectNode | |
Dim GrandChildNode As SubjectNode | |
Dim LeafNode As SubjectNode | |
Dim RootName As String | |
Dim Trees As List | |
Dim i% | |
'----------------------------------------------------- | |
' Use TreeManager.TreeRoot to get the list of subject | |
' root nodes from the tree manager. | |
' There is only one item in this list. | |
'tdc is the global TDConnection object. | |
Set TreeMgr = tdc.TreeManager | |
Set Trees = TreeMgr.RootList(TDOLE_SUBJECT) | |
' Get the name of the subject tree root in your project. | |
RootName = Trees.Item(1) | |
'------------------------------------------------------ | |
' Get the SubjectNode root node object from the | |
' tree manager by name. | |
Set SubjRoot = TreeMgr.TreeRoot(RootName) | |
Debug.Print "Root node : Name = " & SubjRoot.name _ | |
& ", Depth = " & SubjRoot.DepthType _ | |
& ", Path = " & SubjRoot.Path | |
' Root node : Name = Subject, Depth = 2, Path = Subject | |
For i = 1 To SubjRoot.Count | |
Debug.Print SubjRoot.Child(i).name | |
Next i | |
' Flight Reservation | |
' Profiling | |
' Itinerary | |
' Compiled Modules | |
' Cruises | |
' Mercury Tours Site | |
' f1 | |
' BPT Resources | |
' alexk | |
Debug.Print "------------------------" | |
' Get any child node for example. We'll just take the first. | |
Set ChildNode = SubjRoot.Child(1) | |
Debug.Print "Child node: Name = " & ChildNode.name _ | |
& ", Depth = " & ChildNode.DepthType _ | |
& ", Path = " & ChildNode.Path | |
' Child node: Name = Flight Reservation, Depth = 2, _ | |
Path = Subject\Flight Reservation | |
For i = 1 To ChildNode.Count | |
Debug.Print ChildNode.Child(i).name | |
Next i | |
' Flight Finder | |
' Select Flight | |
' Book Flight | |
' Flight Confirmation | |
' Flight Cost | |
Debug.Print "------------------------" | |
' Get a node one level down. | |
Set GrandChildNode = ChildNode.Child(1) | |
Debug.Print "GrandChild : Name = " & GrandChildNode.name _ | |
& ", Depth = " & GrandChildNode.DepthType _ | |
& ", Path = " & GrandChildNode.Path | |
' GrandChild : Name = Flight Finder, Depth = 1, _ | |
Path = Subject\Flight Reservation\Flight Finder | |
For i = 1 To GrandChildNode.Count | |
Debug.Print GrandChildNode.Child(i).name | |
Next i | |
' Son of Flight Finder. | |
' | |
If GrandChildNode.Count > 0 Then _ | |
Set LeafNode = GrandChildNode.Child(1) | |
' | |
' The "Son of Flight Finder" node is not part of the | |
' demonstration project. It was added for this example, | |
' so if you run this code on your site, the routine will exit here. | |
If LeafNode Is Nothing Then Exit Sub | |
Debug.Print "LeafNode : Name = " & LeafNode.name _ | |
& ", Depth = " & LeafNode.DepthType _ | |
& ", Path = " & LeafNode.Path | |
' LeafNode : Name = Son of Flight Finder, Depth = 0, _ | |
Path = Subject\Flight Reservation\Flight Finder\Son of Flight Finder | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment