Wednesday, September 21, 2011
Add a custom webpart to a SharePoint site/page
Wednesday, September 14, 2011
List Item URL (Edit- Link to Item) using CAML query
Wednesday, September 7, 2011
Find the SharePoint web Template ID
Powershell script to find the specific web template details:
Open windows Powershell ISE to execute the comments/scripts. Load the SharePoint assembly if those are not loaded.
To load the SharePoint assembly
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
OR
This assembly can be referred using the “LoadWithPartialName” function which doesn’t require the full assembly information:
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
$web = Get-SPWeb http://portal
write-host "Web Template:" $web.WebTemplate " Web Template ID:" $web.WebTemplateId
$web.Dispose()
Above script can be stored as a .ps1 file and can be executed using SharePoint PowerShell window.
C# code to find out the web template details:
Server Object model can be used for finding out the web template details.
using System;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
using(SPSite site=new SPSite(@"http://sitecoll/"))
{
SPWeb web = site.RootWeb;
Console.WriteLine("Web Name : "+web.Title);
Console.WriteLine("Web Template Name : " + web.WebTemplate);
Console.WriteLine("Web Template ID : " + web.WebTemplateId);
Console.WriteLine("Web GUID : " + web.ID);
}
Console.Read();
}
catch (Exception ex)
{
Console.WriteLine("Error: "+ex.Message);
}
}
}
}
Tuesday, September 6, 2011
Tips on Blank site Template
Taxonomy will not work in Blank site template since the feature is not activate. User has to activate the feature manually. The Taxonomy Feature Stapler attached with global and some of site templates but not with blank site template. The attribute AllowGlobalFeatureAssociations=”False” in blank site template.
To activate Taxonomy Feature using Power Shell
Enable-SPFeature -identity “73EF14B1-13A9-416b-A9B5-ECECA2B0604C” -url “http://sitecollection/”
OR
Enable-SPFeature -identity “TaxonomyFieldAdded“ -url “http://sitecollection/”
To activate Taxonomy Feature using STSADM command
STSADM -o activatefeature -id “73EF14B1-13A9-416b-A9B5-ECECA2B0604C” -url “http://sitecollection/” –force
OR
stsadm -o activatefeature name TaxonomyFieldAdded -url “http://sitecollection/”
Monday, July 25, 2011
Activate Publishing Feature in SharePoint
Feature Stappling is one of the gratest feature in SharePoint. It is easiest way of attaching a feature with existing site definitions without disturbing existing template. This feature will work like plug and play concept. Therefore the features can be attached and enabled by default for any site templates. For example activate the Publishing feature when a Blank site created. This feature has two features one is “Stappler” feature which is used for attaching another feature to the site definition. The another one is “Staplee” feature which get attached with site definition. We have a simple feature stappling demo now.
1. Create a stapler feature and name it as “ActivatePublishingFeature”
2. Find the Staplee Feature GUID because the publishing feature is already deployed in the Farm. In case custom feature, need to use that Feature’s GUID
3. Install the Feature
4. Activate the feature.
xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="ActivatePublishingFeature " Id="f7ff397a-65f1-4e82-ad7d-c75111bceef6" Scope="Farm">
<ElementManifests>
<ElementManifest Location="SitePublishingFeatureElement\Elements.xml" />
ElementManifests>
Feature>
Elements.xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4DA9-A9E3-1F3D343D7ECB" TemplateName="STS#0" />
Elements>
Refer this link to get the GUID of SharePoint 2010 default features.
Refer this link to get the SharePoint 2010 default web templates list
SharePoint 2010 Default web templates
Predefined template IDs can be fetched using PowerShell Command " Get-SPWebTemplate"
Object model Syntax for creating new sub site
public SPWeb Add(
string strWebUrl,
string strTitle,
string strDescription,
uint nLCID,
SPWebTemplate WebTemplate,
bool useUniquePermissions,
bool bConvertIfThere
)
List of Web Templates
Template ID Template Name
GLOBAL#0 Global template
STS#0 Team Site
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multipage Meeting Workspace
CENTRALADMIN#0 Central Admin Site
WIKI#0 Wiki Site
BLOG#0 Blog
SGS#0 Group Work Site
TENANTADMIN#0 Tenant Admin Site
ACCSRV#0 Access Services Site
ACCSRV#1 Assets Web Database
ACCSRV#3 Charitable Contributions Web Database
ACCSRV#4 Contacts Web Database
ACCSRV#6 Issues Web Database
ACCSRV#5 Projects Web Database
BDR#0 Document Center
OFFILE#0 (obsolete) Records Center
OFFILE#1 Records Center
OSRV#0 Shared Services Administration Site
PPSMASite#0 PerformancePoint
BICenterSite#0 Business Intelligence Center
SPS#0 SharePoint Portal Server Site
SPSPERS#0 SharePoint Portal Server Personal Space
SPSMSITE#0 Personalization Site
SPSTOC#0 Contents area Template
SPSTOPIC#0 Topic area template
SPSNEWS#0 News Site
CMSPUBLISHING#0 Publishing Site
BLANKINTERNET#0 Publishing Site
BLANKINTERNET#1 Press Releases Site
BLANKINTERNET#2 Publishing Site with Workflow
SPSNHOME#0 News Site
SPSSITES#0 Site Directory
SPSCOMMU#0 Community area template
SPSREPORTCENTER#0 Report Center
SPSPORTAL#0 Collaboration Portal
SRCHCEN#0 Enterprise Search Center
PROFILES#0 Profiles
BLANKINTERNETCONT... Publishing Portal
SPSMSITEHOST#0 My Site Host
ENTERWIKI#0 Enterprise Wiki
SRCHCENTERLITE#0 Basic Search Center
SRCHCENTERLITE#1 Basic Search Center
SRCHCENTERFAST#0 FAST Search Center
visprus#0 Visio Process Repository