Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Tuesday, March 10, 2009

Create a SharePoint Solution

SharePoint use solution file to deploy solution. There are some tools to create a solution file automatically, like stsdev. But it still important to understand how the solution deployment works

MakeCab does not care about the how to deploy the solution. The job of Makecab.exe is to package all the source file and a ddf file. Sharepoint solution engine take care about of installation and deployment based on the ddf file and the manifest.xml file

The first job is to create a cab file. To create a cab file, makecab.exe need to use the ddf file. the ddf file tells makecab what files need to be packages and how they are organized in the package(what subfolder to hold a file). Below is an exmaple that are generated by the stsdev utility.

; Generated by STSDEV at 3/11/2009 12:26:53 AM

.OPTION EXPLICIT
.Set CabinetNameTemplate=FirstFeature.wsp
.set DiskDirectoryTemplate=CDROM
.Set CompressionType=MSZIP
.Set UniqueFiles=off
.Set Cabinet=on
.Set DiskDirectory1=DeploymentFiles

;*** Solution manifest
DeploymentFiles\manifest.xml

;*** Assembly files
bin/debug/FirstFeature.dll

;*** add files for FirstFeature feature
.Set DestinationDir=FirstFeature
RootFiles\TEMPLATE\FEATURES\FirstFeature\elements.xml
RootFiles\TEMPLATE\FEATURES\FirstFeature\feature.xml

;*** add files for FirstFeature\css feature
.Set DestinationDir=FirstFeature\css
RootFiles\TEMPLATE\FEATURES\FirstFeature\css\mystyle.css


;***********************************
;*** Begin TemplateFiles section ***
;***********************************

.Set DestinationDir=IMAGES\FirstFeature
RootFiles\TEMPLATE\IMAGES\FirstFeature\AfricanPith32.gif

Now we have all the files package the wsp file. Solution Deployment is accomplished in two step, installation and deployment. Installation is to add the package to central admin storage. Deployment is to physically deploy the files to a web server and install the feature to the web server. During installation, the engine will check the manifest.xml and feature_name\feature.xml file to check if all the files required are included in the package. If yes, the installation will succeed. If not, the installation will abort. During deployment, the engine will also use the manifest.xml and feature.xml to copy the files to front end server. It is possible that the package has some files that feature required. In that case, those are just ignored, the engine only copy those files that are shown in manifest.xml and feature.xml. To copy files, the engine does not care about the Module nodes in the element manifest files, it cares about <ElementManifests> in feature.xml, the <TemplateFiles> and <Assemblies> in the manifest. If you file that your wsp file has included the content files, but they are not copied to the front end server, you need to make sure they are shown those nodes.

To install a solution, we can use command line.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o addsolution -filename DeploymentFiles\FirstFeature.wsp

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

To deploy a soltuion, we can use command line,

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o deploysolution -name FirstFeature.wsp -immediate -allowgacdeployment

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

To undeploy a solution,

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o retractsolution -name FirstFeature.wsp -immediate

To uninstall a solution,

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o deletesolution -name FirstFeature.wsp

To upgrade a solution,

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o upgradesolution -name FirstFeature.wsp -filename DeploymentFiles\FirstFeature.wsp -local -allowgacdeployment

This upgrade only update the configuration database, if the solution has been deployed to front end server, the solution need to be redeployed again to the front end server.

In development, we don't really need to use solution deployment, only need to copy the feature file and other content files to folder 12, and install the feature again.

xcopy /e /y "RootFiles\*" "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12"

stsadm.exe -o installfeature 
           {-filename  | 
            -name }
           [-force]

Thursday, March 5, 2009

Global Site Definition

The Global site definition is located at the 12\TEMPLATES\GLOBAL path. It contains the standard default.master page template along with instructions to provision an instance of default.master page into the Master Page gallery of every new site. The Global site definition also contains provisioning logic to create the following four site collection–scoped lists in every new top-level site:Web Parts gallery, List Template gallery, Site Template gallery, User Information Profile list

Site Definition vs Site Template

Site definition are deployed within 12\template\sitetemplates directory and are referenced in 12\template\1033\xml\webtemp*.xml files Wss offer site definitions to provide users with createable site templates out of the box. A site definition named sts prvoides familar site templates such as Team Site, Blank site, and document workspace.

A site definition itself does not represent a creatable site template. Instead, a site definition contains one or more configurations, and these configurations are what appear to users as creatable site templates.

Site definition --contains--> configurations <--referenced by webtemp*.xml --> display configuration as creatable site template

When creating a new site by using the STSADM.EXE command-line utility or through custom code, you are often required to reference a site definition and one of its configurations by name. This is done by specifying the name of the site definition followed by the pound sign and the integer identifier of the configuration. For example, you can use STS#0 to reference the site template titled Team Site and STS#1 to reference the site template titled Blank Site. The following example uses one of these site template references when creating a new top-level site by using the STS command-line utility.

STSADM.EXE -o createsite -url http://site.com
                         -ownerlogin xx\xx
                         -owneremail xx@xx.com
                         -sitetemplate STS#1

Changing a built-in site definitions and templates

One of the challenges in WSS 2.0 was adding new functionality to existing site definitions and templates. This was because the official guidance from Microsoft was to never edit an existing site definition or template once sites have been provisioned using it, and that developers should not modify the site definitions provided in the out - of - the - box installations, as future updates (hotfixes and service packs) could overwrite the files. To address this, Microsoft added the capability of Feature stapling.

Feature stapling involves creating a special Feature, known as a stapling Feature, that associates a Feature with an existing site template. Once a Feature has been stapled to a site template, any future sites provisioned using the site template will automatically activate the stapled Feature. This enables developers to customize site templates without actually changing the site template itself; instead they can append functionality without touching the source files that make up the site template.

Stapling is achieved using the < FeatureSiteTemplateAssociation > site element. This element accepts two attributes: Id , the ID of the Feature to be stapled, and TemplateName , the ID of the site template. For example, the following CAML contained in a Feature element manifest file would staple the MyFirstFeature to all future sites provisioned using the Blank Site site template ( STS#1 ), assuming the stapling Feature were activated:

< ?xml version="1.0” encoding=”utf-8"? > <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="GUID" TemplateName="STS#1" /> </Elements>

Feature used to activate other feature

Sometime you can use a feature simply to activate other features.

<Feature> <ActivationDependencies > <ActivationDependency FeatureId="..." /> </ActivationDependencies > < /Feature >

When to make a feature hidden

When creating a Feature that contains a Feature receiver performing certain tasks that require special permissions, consider making it a hidden Feature, thereby requiring activation via STSADM.EXE. Why? When a Feature is activated from the browser interface, the code is executed within the context of the configured identity of the application pool hosting the Web application containing the site collection. This identity may not have the necessary permissions, such as writing to the file system. However, when a Feature is activated using STSADM.EXE, the identity of the user performing the command is used, who may have more permissions than the application pool’s identity.

Feature Scope

A Feature's scope enables developers quantify how broad the effects of activating the Feature are. If a Feature is scoped at the site level, then activation affects only the SharePoint site it is activated within. However, if it is scoped at a site collection level, then the activation affects all sites within the site collection. To administrator, the scope affect where the feature can be activated to after the feature is installed. If it is farm feature, it can be activated at http://.../_admin/ManageFarmFeatures.aspx, if it is webApplication feature, it can be activated at http://.../_admin/ManageWebAppFeatures.aspx, if it is sitecollection, it can be activated at http://../sitecollection/_layouts/ManageFeatures.aspx?Scope=Site, if it is site feature, it can be activated at http://../site/_layouts/ManageFeatures.aspx

To a developer, the scope affect the receiver's properties.Feature.Parent. For example, if it s a web feature. You can write code like, SPWeb site = properties.Feature.Parent as SPWeb;

Friday, February 6, 2009

Customize SharePoint content page with control

Sharepoint content page can be loaded with custom control, web part and user control. In uncustomized page mode, there is no special requirement for these control. In customized mode, there are some security restriction, they need to be declare as safe control in web.config file. To declare a user control to be safe control, we need to use following syntax in web.config

<SafeControl Src="~/_controltemplates/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />

Thursday, December 18, 2008

How Trace works with Listner

Listner control destination the output of Trace. Here is how.

<trace autoflush="true" indentsize="4"> <listeners> <remove name="Default" /> <add type="System.Diagnostics.ConsoleTraceListener" name="Console" /> </listeners> </trace>

We can also use share sharedListeners, like below.

<trace autoflush="true" indentsize="4"> <listeners> <remove name="Default" /> <add name="Console" /> </listeners> </trace> <sharedListeners> <add type="System.Diagnostics.ConsoleTraceListener" name="Console" /> </sharedListeners>

Forms - Based Authentication

While it is possible to change a newly created SharePoint site collection to use FBA instead of Windows authentication, it is usually a better idea to extend a new Web application from an existing one and configure the new Web application for FBA, leaving the original one set to Windows authentication. There are numerous reasons for this, one being that SharePoint ’ s search uses NTLM (Windows authentication) to authenticate and crawl the site when indexing the content. In the following example, this is the model that is used.

The authentication provider model contains three different providers: membership, role, and profile . The membership provider is the one responsible for the users, including authentication. The role provider is used to determine which users are in which groups. Finally, the profile provider facilitates creating profiles for each user defined in the authentication store. These profiles can contain custom - defined properties along with the standard first and last name, among other properties.

At a minimum, a membership and role provider must be defined. The profile provider is not required, but be aware that omitting it can have adverse effects. For example, a common misperception is that FBA breaks SharePoint ’ s My Site capability. This is not true. My Sites require a profile for the user in order to tie the My Site to the user. If no profile provider is defined, SharePoint cannot create a My Site for that user, which is why many people get the impression that FBA breaks My Sites.

Please ensure the user database for form authentication is accessible.

SharePoint Group

SharePoint allows permission levels to be applied to site users as well as security groups, such as Active Directory groups, that have been added to the site. However, this is not the recommended approach. Rather, Microsoft recommends that site owners and administrators assign permission levels to SharePoint groups and then add site users and security groups to the SharePoint groups.

Friday, December 12, 2008

xxx Approval and Approval Status in list

After a list is enabled "Content Approval", the list has approval status field shows up in the default view. This is system field just like modified, modified by. It has nothing to do with workflow.

The xxx approval field is for workflow xxx. xxx is the workflow name. Even a user approve the workflow in the workflow form, the item's approval status is not necessary synchronized depending your workflow's behavior. To really approve the the item you have to use drop down menu of item, select "approved/reject".

Sunday, December 7, 2008

Site column and field type

They are different concept. Site column is higher level concept, and field type are lower level. Site column reference field type. Site column examples are City, Company, FirstName. It can be reused when create new content type and list. Field type examples are Text, Choice, Notes. But WSS3 allow user to create a customized field types. The motivation for doing this is to gain a greater level of control over initialization, rendering, and data validation that goes on behind a column.

A example of site column is as follow.

<Field ID="{0C5BDEB7-0E0E-4c38-A2E5-F39941E61CE9}" SourceID="http://schemas.microsoft.com/sharepoint/v3" Name="Industry" StaticName="Industry" DisplayName="Industry" Type="Choice" Format="RadioButtons" Group="Litware Columns"> <CHOICES> <CHOICE>High Tech</CHOICE> <CHOICE>Legal</CHOICE> <CHOICE>Medical</CHOICE> </CHOICES> <Default>High Tech</Default> </Field>

A custom field type represents a new data type for columns. A custom field type is wrttern in managed code and compiled into .net assembly that must be installed in GAC. A custom field has two responsibility the business logic, and render UI. So here the UI can be separated into another class, BaseFieldControl.

// example of creating a custom field type public class CompanySizeField : SPFieldText { public CompanySizeField(SPFieldCollection fields, string fieldName) : base(fields, fieldName) { } public CompanySizeField(SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName) { } public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl { get { BaseFieldControl control = new CompanySizeFieldControl(); control.FieldName = this.InternalName; return control; } } // Validate the string. If not valid, throw an SPFieldValidationException public override string GetValidatedString(object value) { if (this.Required || value.ToString().Equals(string.Empty)) { throw new SPFieldValidationException("Company size not assigned"); } return base.GetValidatedString(value); } } // custom field type uses helper class to initialize and render control //this FieldControl use a user control to to render //the TemplateContainer public class CompanySizeFieldControl : BaseFieldControl { protected DropDownList CompanySizeSelector; protected override string DefaultTemplateName { get { return @"CompanySizeFieldControl"; } } public override object Value { get { this.EnsureChildControls(); return this.CompanySizeSelector.SelectedValue; } set { EnsureChildControls(); this.CompanySizeSelector.SelectedValue = (string)this.ItemFieldValue; } } protected override void CreateChildControls() { if (this.Field == null || this.ControlMode == SPControlMode.Display) return; base.CreateChildControls(); this.CompanySizeSelector = (DropDownList)TemplateContainer.FindControl("CompanySizeSelector"); if (this.CompanySizeSelector == null) throw new ConfigurationErrorsException("Corrupted CompanySizeFieldControl.ascx file."); if (!this.Page.IsPostBack) { this.CompanySizeSelector.Items.AddRange(new ListItem[]{ new ListItem(string.Empty, null), new ListItem("Mom and Pop Shop (1-20)", "1-20"), new ListItem("Small Business (21-100)", "21-100"), new ListItem("Medium-sized Business (101-1000)", "101-1000"), new ListItem("Big Business (1001-20,000)", "1001-20000"), new ListItem("Enterprise Business (over 20,000)", "20000+") }); } } }

The field control use a user control as template, so the user control name must be named after the value of DefaultTemplateName property, in this case the name is "ComapanySizeFieldControl" , it should be copied to controltemplates folder.

<SharePoint:RenderingTemplate ID="CompanySizeFieldControl" runat="server"> <Template> <asp:DropDownList ID="CompanySizeSelector" runat="server" /> </Template> </SharePoint:RenderingTemplate>

A backup issue linked with site definition

In WSS, every site is provisioned from a specific site definition. This is true for all top-level sites as well as child sites nested within a site collection. Once a site is provisioned from a particular site defintion, it picks up a dependency on that site definition that remains in effect for the lifetime of the site. A site's dependency on its underlying site defintion can never be removed or changed, and the site definition must be installed and remain functional in the farm for the site to continue working properly.

Consider a scenario in which you create a custom site definition and deploy it within a particular WSS farm. Now imagine that you use this site definition to provision the top-level site within a new site collection. What would happen if you attempted to back up the site collection along with its top-level site by using the STSADM.EXE command-line utility and then restore it in another WSS farm? This would not work properly unless your custom site definition is installed in both farms.

Friday, December 5, 2008

Page Layout

Master pages enable developers and designers to define the overall look and feel of the Publishing site with just a single file, along with some additional branding files such as CSS or images. Just as in ASP.NET 2.0 sites, SharePoint sites also leverage content pages that fill in the content placeholders defined within a master page. Publishing sites take this a bit further by introducing a type of content page called a page layou. Page layouts, when combined with the master page, define the rendering and layout of a page. When the page layout is requested, SharePoint fetches the master page referenced within the SPWeb.CustomMasterUrl property and merges the two together. Developers and designers use page layouts to host editable regions of a page, implemented with Web Parts and field controls.

Page layouts have a special relationship with content types within a Publishing site. Each page layout must be associated with exactly one content type. This content type must inherit from the

Page content type

found in the Publishing Content Types group. Content types are used in a Publishing site to define the schema and rules for a particular type of content. For example, a Press Release content type may have fields for the title and byline, the date of the release, the press release body, optionally some reference links, as well as references with short bios for other companies mentioned in the press release. In addition, it may also have a special workflow associated with it defining a special approval process for the press release.

Keep in mind that the content type only defines the schema and rules for the type of content; it does not address the presentation in any way. This is where page layouts come into play. Page layouts, when combined with a master page, define the rendering/look and feel of a requested page. In addition, developers can associate multiple page layouts with a single content type to give content owners the utmost control in selecting different rendering options for a particular page type. When a content owner initiates the process of creating a new page within a ublishing site, the first thing he or she has to do is select a content type/page layout combination.

Moreover, content owners are not restricted to the page layout that is selected at the time of page creation. At any point in the future, even after the page has been published, a content owner can edit the page and change the selected page layout. The only limitation is that the only page layouts available are those associated with the content type selected when the page was created. This is because a page’s content type cannot be switched from one content type to another after it has been created. In addition, page layouts can only be associated with exactly one content type; no page layout can be associated with more than one content type.

Page layout is the layout of the associated page, which is created using a content type. A Page layout is like a xslt to transform a xml(instance) of a content type(xsd). When I want to edit an instance, this instance is always instance of the associated content type(xsd), not instance of xslt. When create page layout in sharepoint designer, the first step is to select a content type(xsd). And give it a name and title. The page layout will be saved in master page gallary. So the page layout is a file. In class library, page layout inherit from PublishingLayoutPage, which inherit from WebPartPage. In sharepoint, Page Layout is a content type, it inherit from system page layout, which inherit from Page. You can add web part, field control, the field defined in the associated content type(xsd), also available. Below is example of page layout

<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing, Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %> <%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server"> <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/> </asp:Content> <asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server"> <h1>Advance Recruit!</h1> <SharePointWebControls:TextField FieldName="JobTitle" runat="server" id="TextField1"> </SharePointWebControls:TextField> </asp:Content>

The question is master page come into play, when edit page layout in sharepoint , it is render in a master page.

To create instance of associated content type, first you need to enable a content type to a document library. Then select new "the associated content type", you then need to page layout. The page layout can be changed later.

There are two way to edit a page. one is view the page, and then select "Edit Page" in the site action.

Another way is to go the document library of the page, and use the ECB menu. To edit the content of the instance, we can do this in the IE, select the ECB menu, select edit properties. To change the page layout(xslt), we can select ECB menu, select edit in sharepoint designer, sharepoint designer will prompt you, that "The page cannot be edited in sharepoint designer, you can the content in the browser, or edit the corresponding page layout in the sharepoint designer. " , then select edit in browser, then select page menu, select "Page setting and schedule", then change the page layout selection. Below is sample of instance of content type

<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage, Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %> <%@ Reference VirtualPath="~TemplatePageUrl" %> <%@ Reference VirtualPath="~masterurl/custom.master" %> <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> <head> <!--[if gte mso 9]><xml> <mso:CustomDocumentProperties> <mso:PublishingContact msdt:dt="string">1073741823</mso:PublishingContact> <mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023_PublishingContact msdt:dt="string"> System Account</mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023_PublishingContact> <mso:PublishingContactPicture msdt:dt="string"></mso:PublishingContactPicture> <mso:PublishingContactName msdt:dt="string"></mso:PublishingContactName> <mso:ContentTypeId msdt:dt="string"> 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390074DECF7CA992D04DABE3BF7005B8DB9C0002B1A009B64D6C40A65B11619F9CAE59</mso:ContentTypeId> <mso:Comments msdt:dt="string"></mso:Comments> <mso:PublishingContactEmail msdt:dt="string"></mso:PublishingContactEmail> <mso:PublishingPageLayout msdt:dt="string">http://mismitdfyang/_catalogs/masterpage/AdvancedRecruitLayout.aspx, Advance Recruit</mso:PublishingPageLayout> <mso:JobTitle msdt:dt="string">Senior SharePoint Developer</mso:JobTitle> <mso:ScheduleEndNotificationIntervalUnit msdt:dt="string">0</mso:ScheduleEndNotificationIntervalUnit> <mso:Audience msdt:dt="string"></mso:Audience> <mso:ScheduleEndNotificationInterval msdt:dt="string">0</mso:ScheduleEndNotificationInterval> <mso:ReviewRequestInterval msdt:dt="string">0</mso:ReviewRequestInterval> <mso:ReviewRequestIntervalUnit msdt:dt="string">0</mso:ReviewRequestIntervalUnit> </mso:CustomDocumentProperties> </xml><![endif]--> <title>Want ta sharepoint developer</title></head>

It seems to me that page layout is like nested master page. It merge with master page, however, you can add web part, and user contents, and of course most importantly, the field controls generated by associated content type(xsd)

A safe master page

The master page use contentplaceholder as reserve space for the client to fill in it with customized content. If you develop a master page with a placeholder, it is optional for the content page to fill in the placeholder. If the client fill in a placeholder, which is not defined in master page, this will throw an exception. So to be safe, the master page, should have all the placeholder that all client pages use. MSDN has an article about How to create a minimal master page. But is is not necessary, if you develop a master page which will never be applied to the content page out of the box, and it is only used by your customized content page. In this case , you have full control of what place holder be put in the master page.

But you can control the whether the client page's content is visible or not in the master page. There is the trick.

<asp:panel visible=”false” runat=”server”> <asp:ContentPlaceHolder ID=”PlaceHolderPageImage” runat=”server” /> <asp:ContentPlaceHolder ID=”PlaceHolderBodyLeftBorder” runat=”server” /> </asp:panel>

synchronize master page for application page and site page

The master page of application page is under "_layouts" folder, an example is like MasterPageFile="~/_layouts/application.master". Here is trick to demo how to switch it to the site's master page.

public class SuperBrandingModule : IHttpModule { public void Init(HttpApplication context) { context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute); } void context_PreRequestHandlerExecute(object sender, EventArgs e) { Page page = HttpContext.Current.CurrentHandler as Page; if (page != null) { page.PreInit += new EventHandler(page_PreInit); } } void page_PreInit(object sender, EventArgs e) { Page page = sender as Page; if (page != null) { // Is there a master page defined? if (page.MasterPageFile != null) { // only change the application.master files as those are the offenders if (page.MasterPageFile.Contains("application.master")) { SPWeb site = SPContext.Current.Site.RootWeb; if (site.Properties["CurrentMasterPage"] != null) { string CurrentMasterPage = site.Properties["CurrentMasterPage"]; if (!CurrentMasterPage.Equals(string.Empty)) { page.MasterPageFile = CurrentMasterPage; } } } } } } public void Dispose() { } }

SharePoint RPC - URL protocal

You can use URL Protocol in combination with Collaborative Application Markup Language (CAML) and Windows SharePoint Services Remote Procedure Call Protocol (RPC) to post requests to a front-end Web server running Windows SharePoint Services. Use the CAML Method element to post a single request, or a Batch element containing multiple Method elements to post multiple requests, through the post body of a form in an .aspx page. The following programming task shows how to create a form for posting requests. Go to sharpe

http://moss1:9001/sites/team/_vti_bin/owssvr.dll?Cmd=Display&List={86E88F11-F330-4F3D-A475-30056687E39B}&XMLDATA=TRUE

More can be found here

Thursday, December 4, 2008

Site definition

A site definition itself does not represent a creatable site template. Instead, a site definition contains one or more configurations, and these configurations are what appear to users as creatable site templates. Therefore, the STS site definition contains three different configurations: Team Site, Blank Site, and Document Workspace.

Similar to a WSS feature, a site definition is defined with a set of Collaborative Application Markup Language (CAML)-based files that are deployed within a named directory on the file system of each front-end Web server in the farm. Site definitions are deployed within the 12\TEMPLATE\SiteTemplates directory. The core file of the site template is 12\TEMPLATE\SiteTemplates\{sitetemplate_name}\xml\onent.xml. It is referenced in the 12\TEMPLATE\{culture}\XML directory in WEBTEMP.XML files, where the folder is the locale identifier (12\TEMPLATE\1033\XML for US English).

Here is sample of the onet file, it define every thing about the site

A xml file in the 12\TEMPLATE\{culture}\XML folder can contains the configuration of more than one site templates.Here is an exmaple

When creating a new site by using the STSADM.EXE command-line utility or through custom code, you are often required to reference a site definition and one of its configurations by name. This is done by specifying the name of the site definition followed by the pound sign and the integer identifier of the configuration. For example, you can use STS#0 to reference the site template titled Team Site and STS#1 to reference the site template titled Blank Site. The following example uses one of these site template references when creating a new top-level site by using the STS command-line utility.

STSADM.EXE -o createsite -url http://Domain.com
                         -ownerlogin Domain\Administrator
                         -owneremail administrator@Domain.com
                         -sitetemplate STS#1

Wednesday, December 3, 2008

WebPart can be only edit if it is hosted in WebPart Zone

We can add web part into a content page in sharepoint directly, but they can not be customized in share browser, it be customized in sharepoint designer. If you want user to customize it in browser, you have put in web part zone.