Creating Web Sites
SharePoint Designer Developer Reference |
Microsoft Office SharePoint Designer makes Office SharePoint Designer-based Web site creation as easy as creating a new folder on your hard drive. The key to successful Web site management in Office SharePoint Designer is planning the structure and design of your Web sites. With most Web servers, you have one Web site, but with Office SharePoint Designer, you can create as many Web sites as you want, including nested Web sites, called subsites. A Office SharePoint Designer-based Web site comprises three layers—Web site structure, folder structure, and navigation structure. Click one of the links below to select a specific topic.
Understanding Web site structure
Understanding 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 Web site structure
Any folder on your Web server can be a Web site with its own folder hierarchy that can include subsites below the original Web site. When you install Office SharePoint Designer, the program automatically provides a default name for your main Web site. On a disk-based system, the default name is C:\Documents and Settings\user name\My Documents\My Web Sites for Microsoft Windows XP. You may want to name the individual subsites for the various company names themselves, such as Adventure Works, American Society of Science, Mightyflight Toys, or Coho Winery.
Office SharePoint Designer provides a variety of Web site templates—corporate, discussion, customer support, and so on. These templates provide the foundation of the structure for each Web site. For example, Adventure Works may want you to establish a full-blown corporate presence for their Web site; and so on. The Web site hierarchy for a disk-based Web site is shown in the following diagram.
The following figure shows the Web site structure in Folders view. The subsites display a small globe within the folder icon.
Understanding folder structure
The folder structure in Office SharePoint Designer 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 Office SharePoint Designer is similar to opening a window to your Web sites. The folder hierarchy for a disk-based Web site 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 Web sites are displayed in the same view, but you can see from the Web site and folder diagrams that they each have their own structure. A Web site or subsite is a folder. However, a folder that is also a Web site contains meta data about that Web site. For example, if you apply a theme to one of your Web sites, all folders within that Web site will have the same theme. However, you can apply different themes to the Web sites on your Web server. When you change a Web site to a folder, you remove special settings that make that folder a Web site, and settings such as the theme change to match the "global" theme for the disk-based or server-based Web site that provides the container for your Office SharePoint Designer-based subsites.
Understanding navigation structure
You can create files within your Web site, but the navigation structure that links these files to your Web site isn't automatically created when the files are created. However, each subsite can have its own home page. A home page is usually the starting page for any Web site in the navigation structure; but in Office SharePoint Designer 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 the home pages of other subsites that you're maintaining.
The navigation structure contains nodes that link each of the pages in your subsites and provide pointers to the locations of each page in the navigation structure. The navigation structure for a disk-based Web site 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 site. The Coho Winery company wants to add a subsite called Wines Around the World that will start with pages for two regions, Spain and France. The folder structure will contain the Coho Winery Web site and the folder for the subsite, 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 Office SharePoint Designer-based Web sites 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 site.
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 site.
Note
To run the examples in this topic, you must have a Web site called "C:\My Documents\My Web Sites\Coho Winery", or you may substitute a Web site and files of your choice.
|
When you create a Web site with this method, you only create the Web site 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 example adds a home page.
|
Because index.htm or default.htm are file names associated with names commonly used as home pages, Office SharePoint Designer 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 Office SharePoint Designer will not automatically create the navigation structure for you—you will have to add the navigation structure manually as is illustrated in the following example.
Note
The following example creates a new subsite in the Coho Winery Web site and creates two pages in the new subsite: index.htm and Spain.htm.
|
Notice the last statement—the ApplyNavigationStructure 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 LeftSibling parameter: NodeLocationToRightOfSibling, NodeLocationAsLeftmostChild, and NodeLocationAsRightmostChild. Very simply, these constants inform Office SharePoint Designer 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 code adds another page and navigation node to the previous Web site.
|
You can continue to add pages and navigation nodes to your Web site in this way until your Web site is complete. Or, you can create a For loop where you iterate through the Web site adding the number of pages and navigation nodes you need to complete the Web site. The following example adds five pages and navigation nodes to a new subsite in the Coho Winery Web site.
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 site, then make the navigation structure changes, and then apply the navigation structure to the Web site.
|
Creating a Web site with the MakeWeb method
If you already have an existing folder that you'd like to convert to a Web site, you can use the MakeWeb method with a WebFolder object as shown in the following example.
Note
The following example assumes that Webs(0)
is the Coho Winery Web site and that it contains a folder called FolderOne.
|
You will need to create a navigation structure once PageOne is a subsite of Coho Winery.