Sharepoint Object Model

Maybe this is just me again – but I find the relationship between terms used in the SharePoint UI and the SharePoint Object Model (OM) slightly confusing – especially the relationship between the UI Site Collection and Site and the OM SPSite and SPWeb.

SharePoint UI terminology:

a. A Web Application relates to the IIS directory typically created in the ‘inetpub’ directory .

b. The Web Application definition includes the specification/creation of an initial ‘Content Database’ used to store content – though additional Content Databases can be created at a later date.

c. After creating a Web Application you are prompted to create a Site Collection (the collection is stored in the Content Database). The Site Collection is seen as the ‘bridge’ between the logical structures (your content) and the physical implementation (the content database).

d. The Site Collection is identified by the associated URL (which links into the use of managed paths).

e. The creation of a Site Collection includes referencing a SharePoint template – which in turn creates additional libraries and activates features associated with the template.

f. Based on the template you can then create additional Sites within your top-level Site using the SharePoint UI (better thought of as sub-Web sites).

SharePoint Object Model terminology:

a. The Web Application is represented as a ‘SPWebApplication’ object.

b. The Site Collection is actually a ‘SPSite’ object (accessed using the URL in the constructor when creating an instance).

c. To access all Site Collections within a Web Application use the ‘Sites’ property of the ‘SPWebApplication’ (returns a ‘SPSiteCollection’ collection of ‘SPSite’ objects).

d. To access the top-level Web site within a Site Collection use the ‘RootWeb’ property of the ‘SPSite’ object (returns an ‘SPWeb’ object).

e. To access the sub-Web sites of a Web Site use the ‘Webs’ property of the ‘SPWeb’ instance (returns the first level of child web sites).

f. To access all sub-Web sites in a Site Collection use the ‘AllWebs’ property of the SPSite object.

In summary…

SharePoint UI/stsadm Object Model

Web Application SPWebApplication

Site Collection SPSite

Site (aka Web site) SPWeb

The confusion goes on it that if you refer to the SharePoint Content Database management UI this refers to the number of Sites you can have in a Content Database (warnings and maximum) – the UI Site reference in this context refers to a Site Collection.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s