Using the SharePoint Content Editor WebPart

31 07 2009

The ContentEditorWebPart is a web part you can use to display arbitrary HTML and script output on a SharePoint WebPart page.

On a project I’m working on, I provision various ASP.NET pages, features and so on into a site to customize it for the clients application needs. One thing I wanted was some kind of navigation aid to the various ASP.NET pages, and which also allowed the client to use it as part of their own customizations.

To this end I figured the content editor web part could be used to display a menu like list of links to the user, and further I could then provision this webpart using a feature into the web part gallery, thereby making it available for reuse by the client.

Ok so what I wanted was this kind of thing;

rtm01

So, a header that looked like any other webpart header (without the edit arrow) and then a list of links preceeded by an image.

To get the header part I quite unashamedly purloined the same HTML that SharePoint uses to render web part headers, and you can do this quite easily using FireFox (Firebug) and IE8 developer tools, the image below shows this in IE8 by copying the outer HTML of the table which is used to render the Announcements webpart.

rtm02

Having got this HTML I mangled it a bit to remove the “editability” of the header, next onto the list itself. For this I used a table, each row having 2 cells, the first showing an image. Now I wanted it to look like the OOTB Links List, so again using FireFix (Firebug)  / IE8 developer tools I perused the HTML to see what styling and CSS classes SharePoint used to do this, and formatted by HTML accordingly, the results of which looked like this;

<table class="ms-summarycustombody" cellspacing="0" cellpadding="0">
<tr>
<td class="ms-vb" style="padding-bottom:5px;width:20px;vertical-align:middle;text-align:center;">
			<IMG alt="" src="/_layouts/images/square.gif" align="middle"></td>
<td class="ms-vb" style="padding-bottom:5px;">
			<a href="cstools/Basic%20Analysis.aspx"><img src="/_layouts/images/calcis/basic_analysis.jpg" align="middle" border="0" />Open the Basic Analysis Tools</a></td>
</tr>
</table>

So having got the HTML for my header and list, I created an instance of the Content Editor WebPart on a Page and modified it’s properties.

rtm03

Most importantly I turned the Chrome off by setting the Chrome property to None, and set the source HTML to the following;

<TABLE border="0" cellSpacing="0" cellPadding="0" width="100%"><TBODY>
<TR class="ms-WPHeader">
<TD style="width:100%;">
<H3 class="ms-standardheader ms-WPTitle"><SPAN>Reporting Tools</SPAN></H3></TD>
<TD style="padding-right:2px;" align="right">
<DIV class="">&nbsp;</DIV></TD></TR></TBODY></TABLE>
<table class="ms-summarycustombody" cellspacing="0" cellpadding="0">
<tr>
<td class="ms-vb" style="padding-bottom:5px;width:20px;vertical-align:middle;text-align:center;">
			<IMG alt="" src="/_layouts/images/square.gif" align="middle"></td>
<td class="ms-vb" style="padding-bottom:5px;">
			<a href="cstools/Basic%20Analysis.aspx"><img src="/_layouts/images/calcis/basic_analysis.jpg" align="middle" border="0" />Open the Basic Analysis Tools</a></td>
</tr>
</table>

Having done this, I exported the WebPart to a .DWP file

rtm04

So finally we have the finished article;

rtm01

In another post I’ll demonstrate how this WebPart (the exported .DWP file) can be provisioned using a feature.





WSPBuilder: Creating the Deployment Folder

29 07 2009

WSPBuilder is a great tool for packaging your SharePoint features and solutions, and being a command-line tool it’s easy to integrate with your CI / Automated Build environment.

One thing which eluded me though was how to create the deployment folder. With the VS add-in UI it’s easy enough of course, in a CI environment you need a command line switch of some kind, or build step.

It could have been done “manually” in a fairly mungy way I’m sure, but I figured there must be a WSPBuilder command-line switch to do it, although I couldn’t find one in any of the documentation. Sure enough there is, I found it looking through the WSPBuilder checkin comments.

"C:\Program Files\WSPTools\WSPBuilderExtensions\wspbuilder" -CreateDeploymentFolder {option}

The option supports the following values;

  • stsadm – for deployment using STSADM
  • wspbuilder – for deployment using WSPBuilder
  • ssi – for deployment using SharePoint Solution Installer
  • all – create all deployment option targets

While I’m on the subject of WSPBuilder, I can’t reccommend it highly enough, if you’re doing SharePoint development give it a try, if for no other reason than the awesome “Attach to IIS Worker Processes” VS Add-in command.

The WSPBuilder VS Add-in UI

The WSPBuilder VS Add-in UI





What Version / Service Pack of SQL Server am I Running?

28 07 2009

Here’s a handy little script which tells you what version, service pack and edition of SQL Server you’re running.

It’s best to display results as “Text” rather than the “Grid”.

   SELECT   @@VERSION
   SELECT   RTRIM(CAST(SERVERPROPERTY('productversion') AS VARCHAR)) AS [Version],
            RTRIM(CAST(SERVERPROPERTY ('productlevel') AS VARCHAR)) AS [Level],
            RTRIM(CAST(SERVERPROPERTY ('edition') AS VARCHAR)) AS [Edition]

SQL Server Version Information

SQL Server Version Information





6 Part Series: Customizing the User Experience of SharePoint

27 07 2009

There is a great 6 part series on customizing the user experience by Bjørn Furuknap on SharePoint magazine.

The series covers the following topics;

Part 1: Overview of the default SharePoint interface from a technical point of view

In the first article we will look at how the default SharePoint interface is built. We will look at a site, going from top-down, explore some of the the default lists, the fields used to create the basic field types, which content types are available, and how list forms are rendered.

Part 2: Modifying the default experience

This article will show you which options are available for you to modify and improve the default setup. Learn how to override the default rendering of fields or forms without voiding your supported state.

Part 3: Lists and custom list forms

The third article will cover the basics of customizing lists using different views, custom list forms, and fields.

Part 4: Content types user interface

The next article will explore how you can utilize content types to display different input forms and display forms.

Part 5: Custom fields deep dive

Ever wanted to create a new field type? SharePoint enables you to do this and it is a very powerful tool for customizing the user experience.

Part 6: Fast track to feature generation

Writing custom lists with content types by hand can take a massive amount of time. In the final installment I will share with you some tools and techniques that makes list, field, and content type generation very fast.

Bjørn also has an excellant article introducing the reader to SharePoint DelegateControl’s.





13 Part Series on SharePoint Deployment via Features

24 07 2009

André Vala has a great series on developing features for deployment to SharePoint.