Attribute VB_Name = "Module_breadCrumbTrail" ' breadCrumbTrail - Bread Crumb Trail from FrontPage Navigation ' Copyright (c) 2002 Stephen C. Travis ' ' _Insert - Inserts a trail into a page at the cursor location. ' _Update - Updates all existing trails on a page. ' _RecalculateWeb - Updates all trails on all pages in a web. ' ' This program is free software; you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation; either version 2 of the License, or ' (at your option) any later version. ' ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' ' You should have received a copy of the GNU General Public License ' along with this program; if not, write to the Free Software ' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ' or visit their website at http://www.fsf.org/licenses/gpl.txt ' Dim myPageWindow As PageWindow Private Const breadCrumbClass As String = "FP_breadCrumb" Private Const breadCrumbSeparator As String = " >> " Public Sub breadCrumbTrail_Insert() If Not FrontPage.ActiveDocument Is Nothing Then If FrontPage.ActivePageWindow.ViewMode = fpPageViewNormal Then Set myPageWindow = Application.ActiveWebWindow.ActivePageWindow Set myRange = ActiveDocument.selection.createRange myRange.collapse (True) myRange.pasteHTML ("" & breadCrumbTrail() & "") End If End If End Sub Public Sub breadCrumbTrail_Update() If Not FrontPage.ActiveDocument Is Nothing Then If FrontPage.ActivePageWindow.ViewMode = fpPageViewNormal Then Set myPageWindow = Application.ActiveWebWindow.ActivePageWindow Update End If End If End Sub Public Sub breadCrumbTrail_RecalculateWeb() If Not FrontPage.ActiveWeb Is Nothing Then Dim myStartFolder As WebFolder Set myStartFolder = ActiveWeb.RootFolder WalkTree myStartFolder MsgBox ("Done.") End If End Sub Private Function breadCrumbTrail() Dim myHTML As String Dim myRange As IHTMLTxtRange Dim thisNode As NavigationNode On Error Resume Next Set thisNode = myPageWindow.File.NavigationNode If Err <> 0 Then breadCrumbTrail = "" Exit Function End If On Error GoTo 0 myHTML = thisNode.Label Do While thisNode <> ActiveWeb.HomeNavigationNode Set thisNode = thisNode.Parent myHTML = "" & _ thisNode.Label & "" & breadCrumbSeparator & myHTML Loop breadCrumbTrail = myHTML End Function Private Sub WalkTree(myWebFolder As WebFolder) 'On Error Resume Next Dim mySubFolder As WebFolder Dim myFiles As WebFiles Dim myFile As WebFile Set myFiles = myWebFolder.Files For Each myFile In myFiles If IsMember(myFile.Extension, "htm,html,asp,jsp,shtml") Then Set myPageWindow = ActiveWeb.LocatePage(myFile.Url, fpPageViewNoWindow) Update If myPageWindow.IsDirty Then myPageWindow.Save (True) myPageWindow.Close End If Next myFile For Each mySubFolder In myWebFolder.Folders If mySubFolder.Name <> "_borders" Then WalkTree mySubFolder Next mySubFolder End Sub Private Sub Update() For Each Item In myPageWindow.Document.all.tags("span") If Item.Class = breadCrumbClass Then myHTML = breadCrumbTrail() If Item.innerHTML <> myHTML Then Item.innerHTML = myHTML End If Next End Sub Private Function IsMember(strSource, strOptions) strArray = Split(strOptions, ",") IsMember = False For Each Item In strArray If LCase(Trim(strSource)) = LCase(Trim(Item)) Then IsMember = True Exit Function End If Next End Function