FP2000: Publishing to UNIX May Produce Broken Hyperlinks
ID: Q219192
|
The information in this article applies to:
SYMPTOMS
When publishing a web to a UNIX based server, that includes hyperlinks to pages that are in uppercase or mixed case format, the links are broken.
Example:
When you create a hyperlink to a file named "Object.htm", a page within a web, and then publish to a UNIX server, the file is renamed to "object.htm". However, the hyperlinks to the file are not updated to reflect the new filename "object.htm".
Files called "object.htm" and "Object.htm" are recognized as different files on the Unix operating system. Therefore, the links to the file are broken.
CAUSE
Unix operating systems are case sensitive.
RESOLUTION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR
OWN RISK. Microsoft provides this code "as is" without warranty of any
kind, either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
To resolve this issue, use the following code to change the case for all files, folders, and hrefs in the source code.
Sub ToLowerCase()
'/////////////////////////////////////////////////////////////////
'A web must be open for this macro to work. To check to see if a
'web is open, we check the Caption property of the FrontPage
'application. If a web is open, the caption will read
'"Microsoft FrontPage - <web name>". If no web is open, the
'caption will only read "Microsoft FrontPage".
'/////////////////////////////////////////////////////////////////
'Check the caption of the application to see if a web is open.
If Application.ActiveWebWindow.Caption = "Microsoft FrontPage" Then
'If no web is open, display an informational message. . .
MsgBox "Please open a web before running this macro."
'. . . and end the macro.
Exit Sub
End If
'Set up all variables
Dim myWebFiles As WebFiles
Dim myWebFile As WebFile
Dim myWebFolders As WebFolders
Dim myWebFolder As WebFolder
Dim myFile As String
'Set myWebFiles equal to the active web's Files collection
Set myWebFiles = ActiveWeb.RootFolder.Files
'Set myWebFolders equal to the active web's Folders collection
Set myWebFolders = ActiveWeb.RootFolder.Folders
'//////////////////////////////////////////////////////////////////
'In order for us to update the HTML in our files, there must be no
'pages open. To check for this, we check the Count property of
'the PageWindows collection. The PageWindows collection's Count
'property is equal to the number of files that are currently open.
'//////////////////////////////////////////////////////////////////
'Get the count of the PageWindows collection
If ActiveWeb.ActiveWebWindow.PageWindows.Count <> 0 Then
'Set up a variable to hold the result of a message box
Dim myMessageResults As VbMsgBoxResult
'Assign the result of a message box to the variable
myMessageResults = _
MsgBox("Please close all files before running this macro.", _
vbOKOnly, "Microsoft FrontPage")
'If the user clicks OK in our message box, exit the macro.
'This variable will equal vbOK as soon as the user clicks
'the OK button in the message box.
If myMessageResults = vbOK Then Exit Sub
End If
'This For loop loops through each file in the root folder
For Each myWebFile In myWebFiles
'Assign the name of the active file to myFile
myFile = myWebFile.Name
'/////////////////////////////////////////////////////////////////
'We use the Move method to rename the files and folders. When
'we use the Move method to rename files, links are not updated
'automatically. Therefore, we first rename the file
'to "tempname" and then rename it to the lower case equivalent
'of its original name. This forces FrontPage to update the HTML.
'/////////////////////////////////////////////////////////////////
'Rename the file to its temporary name
Call myWebFile.Move("tempname", True, True)
'Now we rename the file to the lower case equivalent of
'its original name.
Call myWebFile.Move(LCase(myFile), True, True)
Next myWebFile
'This For loop loops through each folder that is a subfolder
'off of the root folder.
For Each myWebFolder In myWebFolders
'/////////////////////////////////////////////////////////////////
'When we use the Move method to rename the folders, FrontPage
'will update the HTML links automatically. Therefore, we don't
'need to rename the folders to a temporary name first as we did
'with the files.
'/////////////////////////////////////////////////////////////////
'Rename the folder to its lower case equivalent
Call myWebFolder.Move(LCase(myWebFolder.Name), True, True)
Next myWebFolder
'Since folder names may have changed, we recalculate hyperlinks
ActiveWeb.RecalcHyperlinks
'///////////////////////////////
'Loop through all subfolders
'///////////////////////////////
'Set up a variable as a counter
Dim Count As Integer
'This For loop loops through the Folders collection of the web
For Count = 0 To ActiveWeb.RootFolder.Folders.Count - 1
'Set myWebFiles equal to the current folder's Files collection
Set myWebFiles = ActiveWeb.RootFolder.Folders(Count).Files
'Set myWebFolders equal to the current folder's Folders collection
'This allows us to loop through multiple levels of subfolders
Set myWebFolders = ActiveWeb.RootFolder.Folders(Count).Folders
'This For loop loops through the files in the current folder.
'We use the same method to rename the files as we did above.
For Each myWebFile In myWebFiles
myFile = myWebFile.Name
Call myWebFile.Move("tempname", True, True)
Call myWebFile.Move(LCase(myFile), True, True)
Next myWebFile
'This For loop loops through the folders in the active folder.
'We use the same method to rename the folders as we did above.
For Each myWebFolder In myWebFolders
Call myWebFolder.Move(LCase(myWebFolder.Name), True, True)
Next myWebFolder
Next Count
'Once all of the files and folders are renamed, recalculate hyperlinks
ActiveWeb.RecalcHyperlinks
'Display a message box informing the user that we're done.
MsgBox "Conversion to lower case complete."
End Sub
Additional query words:
fp2k
Keywords : kbdta
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbprb