Skip to content

Create and Use a new Feature for MySites

by on December 23, 2011
  1. Go To C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES
  2. Create a New Folder and rename (i.e. MyCustomFeature)
  3. In the folder, create a new file called “feature.xml” (this will point to your elements.xml file)
  4. Insert the below code replacing the guid (in bold red) with a unique guid for each feature you create (there are alot of online guid creators):<Feature Id=”379BB7B3-AD1E-460D-9647-9A7238018D59
    Title=”My Custom Feature”
    Description=”MyCustomFeature”
    Version=”1.0.0.0″
    Hidden=”TRUE”
    Scope=”Web”
    xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
    <ElementManifests>
    <ElementManifest Location=”elements.xml”/>
    </ElementManifests>
    </Feature>
  5. In the same folder, create a new file called “elements.xml” (this will contain the parts of your feature, some demos show it named other things such as “stapling.xml” which will work as long as it is referenced properly in the above code)
  6. Insert the following code (or your custom info)<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
    <Control Id=”GlobalNavigation” Sequence=”10″ ControlSrc=”~/_controltemplates/newtopn
    </Elements>
  7. Duplicate your selected .ascx file found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES or create one from scratch (NOTE: I like to prepend any customized files/controls or completely custom files/controls with “custom”. For example, CustomMySitesTopNavigation.ascx)

Push out Programmatically with Powershell – use the sharepoint powershell manager on the server

Install

Install-SPFeature -path “MyCustomFeature”

Enable on mysitehost

Enable-SPFeature -identity “MyCustomFeature” -URL http://<mysitehost&gt;

Enable on personal sites

$personalSites = get-spsite | where {$_.RootWeb.WebTemplate -eq “SPSPERS”}
foreach ($site in $personalSites) {Enable-SPFeature -Identity “MyNewNavFeature” -Url $site.Url}

Advertisements
Leave a Comment

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

%d bloggers like this: