Themes


Themes provide a quick way for users to customize their site's look. Behind the scenes, all that is happening is the application of predefined style sheets.

There are two basic types of themes: SharePoint themes and FrontPage themes. SharePoint themes exist as physical content and configuration files on the SharePoint server. These are referenced dynamically in the site's ASPX pages through a SharePoint web control. On the other hand, FrontPage themes originate on the web designer's computer. When a FrontPage theme is applied, the CSS and image files are copied from the client's computer into the SharePoint site. The site's web pages, therefore, become unghosted.

Because FrontPage themes are configured at the web developer's computer rather than at the server level, it is outside the scope of this chapter to go beyond summarizing their functionality. Briefly, each FrontPage theme is packaged within a separate ELM file. These ELM files aggregate several other CSS and image files together. Changes to the theme necessitate unpacking the ELM file, adding, modifying, or deleting the appropriate files, and then repacking them. See Microsoft Support Q295409 article "Unpacking and repacking files in themes in FrontPage" for more detailed information.

As far as the SharePoint server is concerned, a FrontPage theme represents several individual files that are copied to each SharePoint site. Thus, if a FrontPage developer modifies a theme, it is not reflected on a SharePoint site using the old theme unless the developer reapplies the new theme and saves the changes to the site. Separate copies of these theme files exist for each modified site and are stored in the SharePoint database. This implementation makes it exceedingly difficult to make changes to the FrontPage theme across all sites currently using it. In this situation, the web developer must connect to every site using the theme, modify the theme, and then save changes. Managing consistent changes to FrontPage themes in even a small company becomes intolerable.

SharePoint Themes

The general properties of all SharePoint themes are specified within SPTHEMES.XML. The theme's title, description, preview image, and path to its definition are contained within this file. As such, there is an obvious parallel to WEBTEMP.XML.

As shown in Figure 5.1, SPTHEMES.XML is located in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033 folder. The various theme definitions are found as subfolders of C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\THEMES.

Figure 5.1. Layouts/1033 folder with SPTHEMES.XML highlighted.


Although you could modify the existing theme definitions, it is highly recommended to create a new one instead. To that end, let us walk through an example of creating a new theme. This new theme will be entitled My First Theme. First, modify SPTHEMES.XML so that the bolded Templates node shown in Listing 5.1 is added to the bottom.

Listing 5.1. SPTHEMES.XML with My First Theme Added

. . .   <Templates>     <TemplateID>spring</TemplateID>     <DisplayName>Spring</DisplayName>     <Description>Description</Description>     <Thumbnail>../images/thspring.png</Thumbnail>     <Preview>../images/thspring.gif</Preview>   </Templates>   <Templates>     <TemplateID>water</TemplateID>     <DisplayName>Water</DisplayName>     <Description>Description</Description>     <Thumbnail>../images/thwater.png</Thumbnail>     <Preview>../images/thwater.gif</Preview>   </Templates>   <Templates>     <TemplateID>myfirsttheme</TemplateID>     <DisplayName>My First Theme</DisplayName>     <Description>Description</Description>     <Thumbnail>../images/thspring.png</Thumbnail>     <Preview>../images/thspring.gif</Preview>   </Templates> </SPThemes> 

The placement of the Templates nodes within SPTHEMES.XML determines their order in the selection list shown in Figure 5.2. We could have maintained the alphabetical structure of this list by placing the bolded My First Theme Templates node between the Journal and Papyrus theme nodes.

Figure 5.2. Applying My First Theme.


As shown in Listing 5.1, each Templates node in SPTHEMES.XML contains a title (DisplayName), description (Description), images (Thumbnail and Preview), and path to its definition (TemplateID). Addressing the path to the definition and the definition itself is the next step in the process of adding a theme.

Now that we have specified a myfirsttheme folder in SPTHEMES.XML, we must honor our statement. As with site definitions, the preferred way to create a new theme is to copy an old one and modify it as appropriate. Therefore, make a copy of the SPRING folder and rename it MyFirstTheme.

The resulting MyFirstTheme theme, along with all the other theme definitions, is shown in Figure 5.3. However, you are under no obligation to base your theme off the SPRING theme as we did. You could have based it on any of the other themes.

Figure 5.3. Themes folder.


Next, rename the SPRING.INF file to MYFIRSTTHEME.INF. This is done so that it matches the TemplateID specified in SPTHEMES.XML and consequently the folder name. The modified INF filename and the files that define the theme are shown in Figure 5.4.

Figure 5.4. MyFirstTheme folder with a matching MYFIRSTTHEME.INF file.


If we were creating a new theme, we would modify the CSS and images as desired. We also would have specified a new preview image in SPTHEMES.XML to reflect our changes in the theme definition.

The final change requires us to update the title in the renamed INF file. The updated text of MyFirstTheme.INF is bolded in Listing 5.2.

Listing 5.2. MyFirstTheme.INF

[info] title=My First Theme codepage=65001 version=3.00 format=2.00 readonly=true refcount=0 [titles] 1031=Frühling . . . 

After executing an IISReset, your new theme will be fully installed within SharePoint. However, if you receive an error similar to Figure 5.5, you have probably forgotten to update the name of the INF file to match the TemplateID value.

Figure 5.5. Error applying theme.


After your site encounters this error, you will not be able to rename the INF file, execute an IISReset, and then apply the theme again. You will continue to receive the same error. To overcome this issue, you must delete the site that encountered the error, create it anew, and then apply the theme after correctly renaming the INF file.




SharePoint 2003 Advanced Concepts. Site Definitions, Custom Templates, and Global Customizations
SharePoint 2003 Advanced Concepts: Site Definitions, Custom Templates, and Global Customizations
ISBN: 0321336615
EAN: 2147483647
Year: 2006
Pages: 64

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net