Creating Web Sites

   

Some of the content in this topic may not be applicable to some languages.

Microsoft FrontPage makes FrontPage-based web creation as easy as creating a new folder on your hard drive. The key to successful web management in FrontPage is planning the structure and design of your webs. With most Web servers, you have one Web site, but with FrontPage, you can create as many webs as you want, including nested webs. A FrontPage-based web comprises three layers—web structure, folder structure, and navigation structure. Click one of the links below to select a specific topic.

Understanding FrontPage Web Structure

Understanding FrontPage Folder Structure

Understanding Navigation Structure

Creating Web Sites Programatically

Creating a Web Site with the Add Method

Creating a Web Site with the MakeWeb Method

Understanding FronPage Web Structure

Any folder on your Web server can be a web with its own folder hierarchy that can include subwebs below the original web. When you install FrontPage, the program automatically provides a default name for your main web. On a disk-based system, the default name is C:\My Documents\My Webs for a Microsoft Windows operating system or C:\WINNT\Profiles\logon alias\Personal\My Webs for a Microsoft Windows NT operating system. You may want to name the individual subwebs for the various company names themselves, such as Adventure Works, American Society of Science, Mightyflight Toys, or Rogue Cellars.

FrontPage provides a variety of web templates—corporate, discussion, customer support, and so on. These templates provide the foundation of the structure for each web. For example, Adventure Works may want you to establish a full-blown corporate presence for their Web site; and so on. The web hierarchy for a disk-based web is shown in the following diagram.

The following figure shows the web structure in Folders view. The subwebs display a small globe within the folder icon.

Understanding FrontPage Folder Structure

The folder structure in FrontPage behaves in the same manner as the folder structure in Windows Explorer. However, to access these files from Windows Explorer, you have to export them to another location—either your hard drive or server. During the export process, the files are converted to HTML pages. In that sense, opening FrontPage is similar to opening a window to your webs. The folder hierarchy for a disk-based web is shown in the following diagram.

The following diagram shows the folder structure in Folders view.

Note   This diagram displays the same information as the previous one because both folders and webs are displayed in the same view, but you can see from the web and folder diagrams that they each have their own structure. A web or subweb is a folder. However, a folder that is also a web contains meta data about that web. For example, if you apply a theme to one of your webs, all folders within that web will have the same theme. However, you can apply different themes to the webs on your Web server. When you change a web to a folder, you remove special settings that make that folder a web, and settings such as the theme change to match the "global" theme for the disk-based or server-based web that provides the container for your FrontPage-based subwebs.

Understanding Navigation Structure

You can create files within your web, but the navigation structure that links these files to your web isn't automatically created when the files are created. However, each subweb can have its own home page. A home page is usually the starting page for any web in the navigation structure; but in FrontPage you can create alternate pages that exist at the same navigation level as the home page. You may want to add links to a home page that navigate to home pages of other subwebs that you're maintaining.

The navigation structure contains nodes that link each of the pages in your subwebs and provide pointers to the locations of each page in the navigation structure. The navigation structure for a disk-based web is shown in the following diagram.

The following diagram shows the navigation structure in Navigation view.

Creating Web Sites Programmatically

Here's a very simple design for a web. The Rogue Cellars company wants to add a subweb called Wines Around the World that will start with pages for two regions, Spain and France. The folder structure will contain the Rogue Cellars web and the folder for the subweb, Wines Around the World, plus the hidden folder _private, and an Images folder. The navigation structure will contain the Wines Around the World home page (index.htm) and the two child pages (Spain.htm and France.htm—the left and right nodes in the navigation structure).

There are two ways to create FrontPage-based webs in Microsoft Visual Basic for Applications. You can use the Add method with the Webs collection, or you can use the MakeWeb method with a WebFolder object to change an existing folder into a web.

Creating a Web Site with the Add Method

Once you've designed how your Web site is going to look and function, you can use the Set statement as shown in the procedure below to create a new web.

Note   To run the examples in this topic, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). Or, you may substitute a web and files of your choice.

Private Sub Add()
    Dim myNewWeb As WebEx

    Set myNewWeb = _
        Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
End Sub

When you create a web with this method, you only create the web and its folder; you don't create a complete Web site with all of the folders, pages, and navigation in place. The next step is adding a home page. The following statements shown in bold adds a home page and is added to the previous procedure.

Private Sub Add()
    Dim myNewWeb As WebEx
    Dim myFiles As WebFiles Dim myUrl As String

    Set myNewWeb = _
        Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
    Set myFiles = myNewWeb.RootFolder.Files myFileUrl = _         "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm" myFiles.Add(myFileUrl)
End Sub

Because index.htm or default.htm are file names associated with names commonly used as home pages, FrontPage creates the appropriate navigation structure for a home page whenever you use one of these names. However, if you add further pages using the Add method with the WebFile object, you will add pages, but FrontPage will not automatically create the navigation structure for you—you will have to add the navigation structure manually as is illustrated in the following statements shown in bold.

Note   The following example creates a new web in the Rogue Cellars web and creates two pages in the new web: index.htm and Spain.htm.

Private Sub AddCompleteWeb()
    Dim myNewWeb As WebEx
    Dim myFiles As WebFiles
    Dim myUrl As String
    Dim myFileOne As String

    Set myNewWeb = _
        Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
    Set myFiles = myNewWeb.RootFolder.Files
    myFileUrl = _
        "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm"

    myFiles.Add(myFileUrl)
    myFileOne = "C:\My Webs\Rogue Cellars\Wines Around the World\" myFileOne = myFileOne & "Spain.htm" myFiles.Add myFileOne Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _         fpStructLeftmostChild) myNewWeb.ApplyNavigationStructure

End Sub

Notice the last statement in bold—this method applies the changes that you've made to the navigation structure.

There are several constants you can use in the Add method for the Children property: fpStructBaseOnSibling, fpStructLeftmostChild, and fpStructRightmostChild. Very simply, these constants inform FrontPage which position you want to apply to the file in the navigation structure—left, right, or base the position on one of the siblings. Here, myFileOne becomes the leftmost child of the home page. The next step is to add the next page, so that you can view the navigation structure in Navigation view. The following statements shown in bold add another page and navigation node to the previous web.

Private Sub Add()
    Dim myNewWeb As WebEx
    Dim myFiles As WebFiles
    Dim myFileUrl As String
    Dim myFileOne As String
    Dim myFileTwo As String

    Set myNewWeb = _
        Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
    Set myFiles = myNewWeb.RootFolder.Files
    myFileUrl = _
        "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm"

    myFiles.Add(myFileUrl)
    myFileOne = "C:\My Webs\Rogue Cellars\Wines Around the World\"
    myFileOne = myFileOne & "Spain.htm"
    myFileTwo = "C:\My Webs\Rogue Cellars\Wines Around the World\" myFileTwo = myFileTwo & "France.htm"

    myFiles.Add myFileOne
    myFiles.Add myFileTwo
    Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _
        fpStructLeftmostChild)
    Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _         fpStructRightmostChild)

    myNewWeb.ApplyNavigationStructure

End Sub

You can continue to add pages and navigation nodes to your web in this way until your web is complete. Or, you can create a For loop where you iterate through the web adding the number of pages and navigation nodes you need to complete the web. The following example adds five pages and navigation nodes to a new web in the Rogue Cellars web.

Note   Creating, moving, or deleting files and folders while attempting to modify the navigation structure may cause some changes to be lost. First, make the changes to the folder structure of the web, then make the navigation structure changes, and then apply the navigation structure to the web.

Private Sub AddDesignerCrystalWeb()
    Dim myWeb As WebEx
    Dim myParentWeb As WebEx
    Dim myFolders As WebFolders
    Dim myFolder As WebFolder
    Dim myFiles As WebFiles
    Dim myNewFiles(4) As WebFiles
    Dim myChildNode As NavigationNode
    Dim myNewFilename As String
    Dim myFileURL As String
    Dim myCount As Integer
    Dim myBaseURL As String
    Dim myWebURL As String
    Dim myInputMsg As String
    Dim myExist As Boolean

    Set myParentWeb = _
        Webs.Open ("C:/My Documents/My Webs/Rogue Cellars/")
    myParentWeb.Activate

    myBaseURL = "C:/My Documents/My Webs/Rogue Cellars/"
    myWebURL = myBaseURL & "Rogue Cellars Designer Crystal"
    myExist = False
    myInputMsg = _
        "All files will have "".htm"" appended. Type a file name: "
    Set myFolders = Webs(0).RootFolder.Folders

    For Each myFolder In myFolders
        'Check to see if myWebURL already exists.
        If myFolder.IsWeb And myFolder.Url = myWebURL Then
            myExist = True
        End If
    Next

    'Create myWebURL if it doesn't exist.
    If myExist = False Then Webs.Add(myWebURL).Activate
    Set myWeb = ActiveWeb
    Set myFiles = myWeb.RootFolder.Files

    'Create files.
    For myCount = 0 To UBound(myNewFiles)
        myNewFilename = InputBox(myInputMsg)
        myFileURL = myWeb.Url & "/" & myNewFilename & ".htm"
        myFiles.Add myFileURL
        myFiles(myFileURL).Edit
    Next

    'Add to navigation structure.
    For myCount = 0 To UBound(myNewFiles)
        'Check if the current page is index.htm, if so, skip it.
        If myFiles(myCount).Title = "index.htm" Then
            myCount = myCount + 1
        End If
        Set myChildNode = _
          myWeb.RootNavigationNode.Children(0)
        'Add navigation node to the current page.
        myChildNode.Children.Add myFiles(myCount).Url, _
            myFiles(myCount).Title, fpStructLeftmostChild
    Next
    myWeb.ApplyNavigationStructure
End Sub

Creating a Web Site with the MakeWeb Method

If you already have an existing folder that you'd like to convert to a web, you can use the MakeWeb method with a WebFolder object as shown in the following procedure.

Note   This procedure assumes that Webs(0) is the Rogue Cellars web and that it contains a folder called FolderOne.

Private Sub MakeAWeb()
    Dim myWeb As WebEx
    Dim myFolder As WebFolder

    Set myWeb = Webs(0)
    myWeb.Activate
    Set myFolder = ActiveWeb.RootFolder.Folders("FolderOne")
    myFolder.MakeWeb
End Sub

You will need to create a navigation structure once PageOne is a subweb of Rogue Cellars.