DEFAULT.ASPX: The Site s Home Page


DEFAULT.ASPX: The Site's Home Page

The cornerstone of any SharePoint site is its home page. Although the Module section of ONET.XML enables you to set the home page to anything, DEFAULT.ASPX should be the name of your site definition's home page. As discussed previously, the SharePoint site definition templates place this file in the root of the site definition folder (for example, C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\1033\STS).

DEFAULT.ASPX can be modified to your heart's desire. Additional web part zones could be added, icons could be changed, the Quick Launch could be removed, and the list goes on.

To help facilitate your own modifications, let's spend some time deconstructing STS's DEFAULT.ASPX. A typical instance of DEFAULT.ASPX from the STS site definition is shown in Figure 2.24. The major elements include the top blue navigation bar, the bar immediately under navigation bar, the Quick Launch, and the Left and Right web part zones.

Figure 2.24. DEFAULT.ASPX Design view.


Top Navigation Bar

The code that generates the top blue bar is shown in Listing 2.25. The code generates a three-column HTML table row. The first column is a SharePoint team logo. The second column represents the navigation bar we discussed in ONET.XML's NavBars section. The last column is a connection to the parent site, or the portal if the site is the topmost site in the site collection. The content of second and third columns is dynamically generated by web controls from the Microsoft.SharePoint. WebControls namespace.

Listing 2.25. DEFAULT.ASPX Top Bar

 <td nowrap valign="middle">   <img ID=onetidHeadbnnr0 alt="Logo" src="/books/4/78/1/html/2//_layouts/images/logo.gif"> </td> <td class=ms-banner width=99% nowrap  valign="middle">   <!--     webbot       bot="Navigation"       S-Type="sequence"       S-Orientation="horizontal"       S-Rendering="html"       S-Btn-Nml="<a ID='onettopnavbar#LABEL_ID#' href='#URL#'         accesskey='J'>#LABEL#</a>"       S-Btn-Sel="<a ID='onettopnavbar#LABEL_ID#' href='#URL#'         accesskey='J'>#LABEL#</a>"       S-Btn-Sep="&amp;nbsp;&amp;nbsp;&amp;nbsp;"       B-Include-Home="FALSE"       B-Include-Up="FALSE"       S-Btn-Nobr="FALSE"       U-Page="sid:1002"       S-Target startspan   -->     <SharePoint:Navigation LinkBar runat="server"/>   <!--     webbot       bot="Navigation"       endspan   --> </td> <td class=ms-banner>&nbsp;&nbsp;</td> <td nowrap class=ms-banner style="padding-right: 7px">   <SharePoint:PortalConnection runat="server" /> </td> 

Logo, Site Title, Search Box, and SharePoint Modify Page Link

Immediately underneath the top blue bar is a row that contains the home logo, site title and location, search box, and modify shared/personal page link. That code is shown in Listing 2.26.

What might be surprising to learn is that neither the circular home logo nor the "Home" page title is dynamically defined. They are simply coded as static links. Thus, it is very straightforward to reference another URL for the home icon or change the page title to something else.

The only things that are dynamically defined within that row are the site's description, the search box, the modify shared/personal page link, and the authentication button. These dynamic generations are powered by web controls from the Microsoft.SharePoint.WebControls and Microsoft.SharePoint.WebPartPages namespaces.

As you build your own site definition templates, you should consider upgrading Windows SharePoint Services' weak search support. WSS only enables you to search the current site. It does not search subsites or parent sites. Because it does not declare this weakness, users usually do not realize that content might exist in a subsite even though it did not show up in the search results.

Although this weakness is being solved in the next version of Share-Point, Microsoft has released an upgraded search box as an interim solution. Specifically, Anthony Petro's MSDN article "Creating a Site Context Search Box that Uses SharePoint Portal Server Search Results" includes an updated search box that can be integrated into DEFAULT.ASPX or any other site definition page. Anthony's search web part enables the user to select the context (site, site collection, or all content indexed by SharePoint Portal Server) of his or her search and uses SharePoint Portal Server to generate the results. The web part posts the search query along with its context to SharePoint Portal Server's search page through the querystring. The next version of Share-Point will expand on this idea.

Listing 2.26. DEFAULT.ASPX Logo, Title, Search Box, Settings Link, and Authentication Button

 <td align=center nowrap style="padding-top: 4px" width="132"     height="46">   <img ID=onetidtpweb1 src="/books/4/78/1/html/2//_layouts/images/home.gif" alt="Icon"        height="49" width="49"> </td> <td>   <IMG src="/books/4/78/1/html/2//_layouts/images/blank.gif" width=22 height=1 alt=""> </td> <td nowrap width="100%" style="padding-top: 0px">   <table cellpadding=0 cellspacing=0>     <tr>       <td nowrap >         <SharePoint:ProjectProperty Property="Title" runat="server"/>       </td>     </tr>     <tr>       <td ID=onetidPageTitle >         Home<!-- -->       </td>     </tr>   </table> </td> <td align=right valign=top>  <table cellpadding=0 cellspacing=0 height=100%>    <tr>      <SharePoint:ViewSearchForm          Prompt="Search this site"         Go="Go"         Action="searchresults.aspx"         runat="server"/>    </tr>    <tr style="padding-right:1px">      <td colspan=5 nowrap style="padding-bottom: 3px; padding-top:                                  1px; vertical-align: bottom"          align=right >        <span class='ms-SPLink'>          <span class='ms-HoverCellInActive'              onmouseover="this.className='ms-HoverCellActive'";              onmouseout="this.className='ms-HoverCellInActive'">            <WebPartPages:SettingsLink runat="server"/>          </span>        </span>        <WebPartPages:AuthenticationButton runat="server"/> &nbsp;      </td>    </tr>  </table> </td> 

Quick Launch Bar

One would expect the Quick Launch bar to be a single web part. However, it is composed of several web parts, one for each list type.

The code snippet in Listing 2.27 provides a window into how the Documents section of Quick Launch is generated, and it is representative of the other sections. The Documents text is statically defined and links to VIEWLSTS.ASPX with a querystring parameter. The querystring parameter filters the page for document libraries.

Listing 2.27. DEFAULT.ASPX QuickLaunch

 <TR>   <TD >     <A HREF="_layouts/<% =System.Threading.Thread.CurrentThread.CurrentUICulture.LCID          %>/viewlsts.aspx?BaseType=1">       Documents      </A>   </TD> </TR> <TR>   <TD style="height: 6px">     <!--       webbot bot="Navigation"              S-Btn-Nobr="FALSE"              S-Type="sequence"              S-Rendering="html"              S-Orientation="Vertical"              B-Include-Home="FALSE"              B-Include-Up="FALSE"              U-Page="sid:1004"              S-Bar-Pfx="<table border=0 cellpadding=4 cellspacing=0>"              S-Bar-Sfx="</table>"              S-Btn-Nml="<tr><td><table border=0 cellpadding=0                         cellspacing=0><tr><td><img                         src='/books/4/78/1/html/2/_layouts/images/blank.gif'                         ID='100' alt='Icon' border=0>&amp;nbsp;</td>                         <td valign=top><a ID=onetleftnavbar#LABEL_ID#                          href='#URL#'>#LABEL#</td></tr></table></td>                          </tr>"               S-Target TAG="BODY"               startspan       -->         <SharePoint:Navigation LinkBar runat="server"/>      <!--        webbot bot="Navigation"               endspan     -->   </TD> </TR> 

The site's document libraries are enumerated immediately below the static Documents text. This dynamic generation is made possible through the Microsoft.SharePoint.WebControls.Navigation web control class. The site's document library instances are formatted with regard to a NavBar defined within ONET.XML. In the current case, Documents links back to the NavBar with an ID of 1004. The Documents NavBar is detailed in Listing 2.28.

Listing 2.28. Documents NavBar

 <NavBar Name="Documents"            Prefix="&lt;table border=0 cellpadding=4 cellspacing=0&gt;"            Body="&lt;tr&gt;&lt;td&gt;&lt;table border=0 cellpadding=0                  cellspacing=0&gt;&lt;tr&gt;&lt;td&gt;&lt;img                  src='/books/4/78/1/html/2//_layouts/images/blank.gif' ID='100' alt='Icon'                  border=0&gt;&amp;nbsp;&lt;/td&gt;&lt;td                  valign=top&gt;&lt;a ID=onetleftnavbar#LABEL_ID#                  href='#URL#'&gt;#LABEL#&lt;/td&gt;&lt;/tr&gt;&lt;                  /table&gt;&lt;/td&gt;&lt;/tr&gt;"            Suffix="&lt;/table&gt;" > </NavBar> 

Site Description and Web Part Zones

The last elements are the description property and web part zones as shown in Listing 2.29.

The description is generated from the ProjectProperty class with a Property attribute set to Description. Recall that the site's title was rendered in the same fashion except for the Property attribute being set to Title.

Listing 2.29. DEFAULT.ASPX Description and Web Part Zones

 <form runat="server">   <table style="margin-top: 4px" cellpadding="3" cellspacing="0"          border="0" width="100%">     <tr>       <td  valign="top" colspan=4>         <SharePoint:ProjectProperty Property="Description"                                     runat="server"/>       </td>     </tr>     <tr>       <!-- Middle column -->       <td valign="top" width="70%">         <WebPartPages:WebPartZone runat="server"                                   FrameType="TitleBarOnly"                                                                      Title="loc:Left" />         &nbsp;       </td>       <td>&nbsp;</td>       <!-- Right column -->       <td valign="top" width="30%">         <WebPartPages:WebPartZone runat="server"                                   FrameType="TitleBarOnly"                                                                      Title="loc:Right" />         &nbsp;       </td>       <td>&nbsp;</td>     </tr>   </table>   &nbsp;   <!-- FooterBanner closes the TD, TR, TABLE, BODY, And HTML regions        opened above -->   &nbsp; </form> 

DEFAULT.ASPX has two web part zones. In our example, we have Left and Right web part zones. Both web parts have their FrameType, ID, and Title attributes specified. These and other attributes are defined in Table 2.13.

Table 2.13. WebPartZone Properties

Attribute

Required

Type

Description

AllowCustomization

No

Boolean

If trUE, the shared page view of this web part zone can be modified.

AllowPersonalization

No

Boolean

If TRUE, the personal view of this web part zone can be modified.

ContainerWidth

No

Text

Specifies any valid CSS width value (for example, 50px) for the zone. Note that this is considered a hint and is not guaranteed to be honored.

FrameType

No

Text

Specifies the default frame type for web parts added to this zone.Valid frame types include Default, None, Standard, and TitleBarOnly.

ID

Yes

Text

Specifies an ID that will be referenced by ONET.XML to add web parts to the specified web part zone.

LockLayout

No

Text

If FALSE, web parts within this zone can be added, deleted, resized, and moved.

Orientation

No

Text

Specifies the direction web parts will be placed in the zone. Valid values include Horizontal and Vertical.

Title

No

Text

Specifies a friendly name for the web part zone.


As you start to experiment with adding web part zones to your pages, you will discover that WebPart and WebPartZone controls must live in a runat='server' HtmlForm. You will therefore have to move the form tag to surround all WebPart and WebPartZone controls. Depending on where you place the opening and closing form tag, you can run into a somewhat confusing error: The Controls collection cannot be modified because the control contains code blocks (that is, <% . . . %>). ASP.NET complains because ASPX code blocks (<% . . . %>) cannot exist within a form tag that is run at the server. Assuming you didn't put any additional ASPX code blocks into your DEFAULT.ASPX page, the only ASPX code blocks are from Quick Launch. Quick Launch uses the code blocks to determine the LCID of the SharePoint server. This value is then embedded within a dynamically generated URL. Your options now include building a custom web control to render the LCID, removing the Quick Launch from the home page, hard coding the LCID into the site definition, using client-side JavaScript, or some hybrid. Whichever option you choose, it should be relatively easy to navigate around this issue.




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