Provisioning files in a feature in the root directory

I was recently tasked with migrating code that was written for 2007  in a feature. The files that were originally provisioned in the feature we deployed to the root folder of the feature. The code had already been upgraded to SharePoint 2010. I needed to create a wsp using Visual Studio 2010 and package it as a feature. Out of the box when you create a new Module in VS 2010 you get a subfolder so for example you create the feature called Feature1 and a module called Mod1. The default deployment path is 14\templates\features\feature1\mod1\file.txt. What I needed was feature1\mod1\file.txt. I tried modifying all the attributes in the elements.xml file and was not able to get the files to the correct location.

 

In the end what i did was the following

  1. Add the file to the module in visual studio
  2. Look at the properties of the file in visual studio
  3. Under Deployment Location expand the + and clear the Path value.
  4. Ensure that the Deployment Type is Element File
  5. Deploy the file and it should be in the correct location.

Custom Search MasterPage for SharePoint 2010

I wish I could say that I was smart enough to have figured this one out for myself but I can’t. I was working on my first custom branded SharePoint 2010 site and the search screen was all messed up. The navigation was displaying doubled. It turns out that the search center out of the box used minimal.master. This uses the placeholders that are in v4.master in different way so the search box ends up in the breadcrumb pull down. At any rate, Randy Drisgill wrote a great and very easy to follow post about how to modify your custom masterpage to the search center. It took me longer to create the feature to deploy the new search masterpage than it did to make the modifications.

Defaulting Preview Pane To First Item in List

A client of ours wanted to use the preview pane for a list view. The default view of the preview pane has the right hand pane blank. You need to select an item or hover an item from the left pane to populate the right pane. The client wanted the right hand pane to have the right hand pane default to first item in the list.

 

  • Add a reference to Jquery into the master page.
  • On the list view page add a content editor web part.
  • To do this go to the list view page and add ?ToolPaneView=2 to the query string. This brings the list view page into edit mode where you can add a web part to it.
  • In the content editor web part add the following JQuery.$("document").ready(function () { $('div.ms-ppleft table tr td.ms-vb-title').first().trigger('onfocus'); //click(); })
  • Save the page.
  • The preview pane should now default to the first item in the list.

Powershell Commands for Installing Solutions and Features

As a SharePoint 2007 developer I have many of the common stsadm commands committed to memory. While stsadm still works in SharePoint 2010 in favor of moving to proficiency in the latest version of the technology here are some of the powershell commands that I use on a daily basis. With that said, I usually create a batch file that runs these commands so that I only need to run one command to get the features updated and features activated.

Add Solution
Add-SPSolution c:\solutions\myproject.wsp

Deploy Solution
Install-SPSolution –Identity myproject.wsp –WebApplication http://myprojectsite -GACDeployment
Note: You can also use the following parameters

  • –CASPolicies: If you are not deploying to the GAC
  • –AllWebApplications: if you want to deploy the solution to all web applications
  • –Force: to force the deployment of the solution

Upgrade Solution
Update-SPSolution –Identity myproject.wsp –LiteralPath c:\solutions\myproject.wsp –GACDeployment

Retract Solution
Uninstall-SPSolution –Identity myproject.wsp –WebApplication http://myprojectsite

Remove Solution
Remove-SPSolution –Identity myproject.wsp

Activate Feature
Enable-SPFeature –Identity MyFeature –url http://myprojectsite

Deactivate Feature
Disable-SPFeature –Identity MyFeature –url http://myprojectsite