Thursday, July 30, 2009

Audience Targeting for Quick Launch using CEWP in SharePoint

I have seen this query in communities to hide the Quick Launch for a user group / particular audience. Most of the SharePoint developers know that Content Editor Web Part can be used to hide the Quick Launch bar.

To achieve the same, add the CEWP to the page, where you do not want to display the Quick Launch. Open Source Editor of CEWP and add the following

<style>
.ms-quicklaunch
{
display:none;
}
.ms-navframe
{
display: none;
}
</style>


Once the above <style> has been added, go to Advance Setting, set “Audience Targeting”. Set the group/audience to which you do not want to display the Quick Launch bar.

I have set the “Visitors” group in Audience Targeting. This setting will not allow the “Visitors” to see the Quick Launch bar.

I have a moss_user1 in Visitors Group and moss_user2 in Members Group.



The below screen hides the Quick Launch for moss_user1 (Visitors Group)



See the following screen, which shows the Quick Launch for moss_user2 (Members Group)


This approach will work for a single page, if you want the same to apply for all pages then add the CEWP to the master page with the above specified settings.

SharePoint Custom Search using FullTextSqlQuery – Format Hit Highlighted Summary

SharePoint search uses “HitHighlightedSummary “column for highlighting the search text in result summary. Querying the HitHighlightedSummary column using FullTextSqlQuery returns the data that contains hit highlights that are surrounded with tags like <c0>…</c0>

This hit-highlight can be easily customized in OOB search core result web part by customizing the xsl. If it is a custom web part and using FullTextSqlQuery then we need to write piece of code to format hit-highlights.

public static string FormatHitHighlightedSummary(object text, string highlightedTag)
{
return Regex.Replace(Regex.Replace(text.ToString(), @"<c\d>", string.Format("<{0}>", highlightedTag), RegexOptions.IgnoreCase), @"</c\d>", string.Format("</{0}>", highlightedTag), RegexOptions.IgnoreCase);
}


While binding the Highlighted Summary, use the above created method as shown below
<%# FormatHitHighlightedSummary(Eval("HitHighlightedSummary"), "i")%>

I’ve used “Italics - <i>” to Highlight the search text… Use this method to format highlighted summary depends on your requirement.

Wednesday, July 29, 2009

SharePoint Custom Page Layout – Web Parts getting added twice

I have used SharePoint Designer to create a custom page layout and added few custom web parts (drag-drop using SPD).

The Page Layout has been deployed using a Feature. After deployment, The Page Layout has web parts as expected and the issue is, when a page is created using the custom Page Layout, each web part is added twice.

I have tried different approaches to remove the web parts unsuccessfully. Finally removed all web parts (which I have added using SharePoint Designer) and used “
AllUsersWebPart” element to add custom web parts in Feature. It worked like a charm!

Monday, July 27, 2009

Useful Tools for SharePoint

The following are the tools which are very frequently used in SharePoint Projects.

SharePoint Designer

SharePoint Designer is a WYSIWYG HTML editor and web design application from Microsoft exclusively for SharePoint sites.

Download link: http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42&displaylang=en

U2U CAML Builder

A tool for creating and executing CAML queries

Download link: http://www.u2u.be/res/Tools/CamlQueryBuilder.aspx

SP Dispose Check

A tool for writing safe code using SharePoint Object Model to prevent memory leaks

Download link: http://code.msdn.microsoft.com/SPDisposeCheck

WSPBuilder

A tool for creating SharePoint Solution Package (WSP) WSS 3.0 & MOSS 2007

Download link: http://www.codeplex.com/wspbuilder

STSDEV

A tool for creating easy deployable solution

Download link: http://www.codeplex.com/stsdev

SharePoint Manager 2007

It a SharePoint object model explorer tool, enables you to browse every site on the local farm and view every property.

Download link: http://www.codeplex.com/spm

WSS/MOSS Log file reader

A tool to View, search and filter SharePoint ULS log files directly from within Central Administration.

Download link: http://www.codeplex.com/wssmosslogfilereader


SharePoint Logging Spy

A tool to allow real time diagnostics of multiple servers in a SharePoint

Download link: http://www.codeplex.com/sharepointloggingspy

SharePoint Test Data Population Tool

A tool for capacity planning and performance testing that populates data for testing SharePoint deployments

Download link: http://www.codeplex.com/sptdatapop

AD Explorer

It is an advanced Active Directory (AD) viewer and editor which allows manipulation of AD objects

Download link: http://technet.microsoft.com/en-us/sysinternals/bb963907.aspx

IE Developer Toolbar

A tool that aims to aid in design and debugging of web pages

Download link: http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

Note: “Internet Explorer 8” includes the features of IE Developer Toolbar built in, instead of a separate product; known as Developer Tools rather than Developer Toolbar.

Reflector

A tool for disassemble Assemblies

Download link: http://www.red-gate.com/products/reflector

GhostDoc

A tool that helps developers writing XML documentation comments

Download link: http://www.roland-weigelt.de/ghostdoc

Resource Refactoring

A tool to extract hard coded strings from the code to resource files

Download link: http://www.codeplex.com/ResourceRefactoring

Fiddler

It is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet.

Download link: http://www.fiddlertool.com/

Saturday, March 28, 2009

SharePoint Excel Services – Session Management

A session will be generated whenever a user views a workbook in browser using Excel Services. The session settings for excel services can be configured in SSP. To configure these settings, navigate to SSP site and click on “Edit Excel Services Settings” from “Excel Services Settings” section.



The default session per user is 25. You can even use “STSADM” command line utility to configure the Excel Services Session management setting.

STSADM.EXE –o set-ecssessionmanagement –ssp mysharedservice
-maxsessionperuser 40

This will increase the session per user to 40.

Friday, March 27, 2009

Excel Web Access - Unable to Load Workbook

The Excel web access will throw the following error when the associated workbook is created using Office Excel 2003 / lower.


Error:
The workbook that you selected cannot be opened.
The workbook may be in an unsupported file format, or it may be corrupt.








Use Office Excel 2007 to create the workbook and save it to your library (trusted location) and now the Excel Web Access web part will display the workbook.

Saturday, February 28, 2009

Site Aggregator Web Part of SharePoint

Site Aggregator is a simple and straight-forward web part, can be used to display sites (specific page in a site) of our choice.

The following are the important properties of Site Aggregator WebPart.

Properties of Site Aggregator

1. Number of characters before ellipses
Sets the number of characters that should be rendered in a tab before truncating and showing ellipses

Default value of this property is 30


2. Number of tabs to show before more dropdown
Sets the number of tabs that should be rendered before additional items are put in the more dropdown

Default value of this property is 5

3. URL
This URL fragment will be appended to the site URL when a tab is selected

Default value of this property is MyInfo.aspx (_layouts/MyInfo.aspx).

I have used “Site Content and Structure” page (_layouts/sitemanager.aspx) page. This will help managers to easily navigate and review “Pending Approvals” or other task of all sites from a same page.

Add the “Site Aggregator” to your page and set the Target Audience property to Managers or the respective approver group, so that only managers/approvers can see this web part.



Use “New Site Tab” from Sites menu to create a new Site Tab.



Set the URL property to “_layouts/sitemanager.aspx”. See the below image for the properties of Site Aggregator.



After adding all the sites, select the “Pending Approval” view to see all the approvals which are pending for the selected site.



Managers / Approvers can manage all approvals or view other details in same page.