Wednesday, March 24, 2010

Backup SharePoint 2010 Site, Backup-SPSite

To create a backup of your SharePoint 2010 site collection:

* Go to Start > Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell.



* Type this command on the prompt.

Backup-SPSite -Identity http://sitecollectioname/ -Path "C:\BackupFolder\BackupFilename.bak" -NoSiteLock -SqlSnapshot -Verbose


* Change the name of the SiteCollection as per yours. And also change the name of the Backup Folder and Backup Filename as you like.


* MSDN reference.

Thanks,

JK

Monday, March 15, 2010

Display Content Query Web Part contents as Dropdown in SharePoint 2010

Objective:

To display Content Query Web Part contents as a dropdown in SharePoint 2010. The dropdown will contain list of the documents from the document library/libraries in the site.
To open up a selected document in the dropdown, create a button next to dropdown that will load the document as user clicks the button.

Solution:

A) Modify ContentQueryMain.xsl and ItemStyle.xsl

Copy XSL Files to New Location

a) Open your site in SharePoint Designer 2010.
b) Click on All Files --> Style Library --> XSL Style Sheets (if you dont find these folders then go to site collection settings and enable publishing feature on site collection level and site level)
c) Create a new folder called Dropdown under XSL Style Sheets folder so that we dont modify original xsl files and have our own customized xsl files pointing from content query web part.
d) Copy ContentQueryMain.xsl, ItemStyle.xsl and Header.xsl from XSL Style Sheets folder and paste it under Dropdown folder which you created.

Modify ContentQueryMain.xsl file

e) Open the file ContentQueryMain.xsl from Dropdown folder in edit mode.

Create Dropdown in the XSL

f) Add the code circled with red line in OuterTemplate.Body template before for loop

g) Add the code circled with red line at the end of OuterTemplate.Body template after closing tag of for loop




h) Add the code circled with red line in OuterTemplate.CallItemTemplate


i) Close ContentQueryMain.xsl file. We dont need any further modifications in it.

Modify ItemStyle.xsl file

j) Open the file ItemStyle.xsl from Dropdown folder in edit mode.

Propogate items in Dropdown

k) Copy the complete 'TitleOnly' template and paste it at the end of the file to create your own style and change/add the code circled with red line. You can see that in the image below. Make the template look as shown below:

l) Close the ItemStyle.xsl file. We dont need any further modifications in it.


B) Assign the customized XSL files to Content Query Web Part.

a) Add a CQWP on any page on your site.

b) Edit Web Part properties and assign Source, List Type, Content Type etc to display items.

c) After applying changes, you can see the list of the documents in CQWP.

d) Export the web part and save the file.

e) Open the file in any editor and change the following properties as shown in the image below.

f) You can change other properties as required. i.e. Title, Content Type etc.

g) Save the file then import the web part on any page on the site.

h) You might have to change the properties of the web part if 'Go' button redirects to another page and does not open the document.

1) Edit Web Part
2) Open 'Presentation' details.
3) On Link textbox, enter 'URL Path;'(no single quote) and on Title textbox, enter 'Title;'(no single quote)



4) Click Ok to save the values. Select the value from dropdown then click Go. It will open up the document.


I tried to explain it in a simple way.. I hope there will be no problems implementing this solution. If you have any problems just drop me an email.

Please, do provide comments for the post.

Thanks,
JK