Friday, May 23, 2008

SharePoint Tool Pane, where are you?

A colleague of mine are creating a new master page for an ECM site. Once all SharePoint controls were included into the new master page, we found that the tool pane (the one that shows web part properties) went off the grid, not restricted by the boundary of HTML tables etc.

After some research, it is concluded that the mater page need to include a PlaceHolder tag with an ID of “MSO_ContentDiv”. Followed by the PlaceHolder is a HTML table tag with an id of “MSO_ContentTable”. Both of these tags can be found in OOB SharePoint master pages. Once these two tags are in place, the tool pane attaches itself to the left side of this HTML table when it is summoned.

Thursday, May 15, 2008

Extending SharePoint Page Layout

Found this blog entry from Janne Mattila's regarding extending page layout to include your own funky stuff. The example given are for custom language change, dynamic master page change and dynamic page layout swapping. For my case, I needed to do this to capture statistics of page hits for specific pages. Refer to here for more details.

Updating SPListItem from code

I was writing some codes to update some of the SPListItem column values. Typically after changing the column values of an SPListItem, you have to invoke the SPListItem.Update() method to commit the changes. Later on I found out there’s two other update method, namely SPListItem.SystemUpdate() and SPListItem.UpdateOverwriteVersion().

SystemUpdate() updates the SPListItem without affecting the system dates of the item and version number. So this is useful for my case as my little console application are performing mass update from behind the scene. As for UpdateOverwriteVersion(), I’m not sure what it does, base on description it overwrites the current version, which I think would affect the system dates and version.

 

More reference at MSDN:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.systemupdate.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.updateoverwriteversion.aspx

Wednesday, May 7, 2008

Changing Links List In SharePoint 2007 To Open In New Browser Window

Much to my disappointment, Links list in MOSS 2007 still does not have the feature to set whether the link should open a new browser window when the user clicks on the URL value. There’s quite a handful of blogs writing how to do this. Here’s my take on how I go about doing it.

1. Create a new content type, inheriting from Links list. I’ll call it Custom Links

2. Add a new site column to the Custom Links content type call “Open In New Browser” of type Boolean (Yes/No). This column will indicate whether the hyperlink should open in a new browser window or on existing browser window.

3. Add some hyperlinks into the list. This will help visualization during modification in SharePoint designer.

4. For my case, my users will only view Custom Links using several custom views. So I use the SharePoint Designer approach. Locate and open the view pages in SharePoint Designer.

5. Right-click on the Custom Lists web part and select “Convert To XSLT Data View”.

6. Locate the URL field by clicking on the URL value on screen.

7. Referring to the screenshot, immediately after the xsl otherwise tag, replace the whole chunk of code starting from the Anchor tag with the following:

<xsl:choose> <xsl:when test="@Open_x0020_In_x0020_New_x0020_Br='1'"> <A onfocus="OnLink(this)" HREF="{substring-before(@URL, ', ')}" target="_blank"> lt;xsl:choose> <xsl:when test="substring-after(@URL, ', ')=''"><xsl:value-of disable-output-escaping="no" select="substring-before(@URL, ', ')" /></xsl:when> <xsl:otherwise><xsl:value-of select="substring-after(@URL, ', ')" /></xsl:otherwise> </xsl:choose> </A> </xsl:when> <xsl:otherwise> <A onfocus="OnLink(this)" HREF="{substring-before(@URL, ', ')}"> <xsl:choose> <xsl:when test="substring-after(@URL, ', ')=''"><xsl:value-of disable-output-escaping="no" select="substring-before(@URL, ', ')" /></xsl:when> <xsl:otherwise><xsl:value-of select="substring-after(@URL, ', ')" /></xsl:otherwise> </xsl:choose> </A> </xsl:otherwise> </xsl:choose>

8. Optional: Somehow the URL column became not sortable and has a funny formatting. Easily fixed by making it sortable again by changing the sortable value to 1.

Additional references that uses different methods below: http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=254 http://www.andrewconnell.com/blog/articles/SharepointLinksListOpenInNewWindow.aspx http://weblogs.asp.net/bsimser/archive/2005/02/07/368326.aspx

Monday, May 5, 2008

Rendering of SharePoint controls base on user permission

The SharePoint server control SPSecurityTrimmedControl can be used to control rendering of page elements/components base on user’s permission. The PermissionsString  property can be used to specify users with what permissions are allowed viewing of the page element/components within. For a list of possible PermissionsString, refer to http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spsecuritytrimmedcontrol.permissionsstring.aspx. More information at Mark Wagner’s blog.

Adding items to the end of a breadcrumb

This blog from Danny Chan gives some idea on how to add some additional items at the end of the breadcrumb on MOSS 2007. Check it out at http://weblogs.asp.net/dannychen/archive/2005/10/19/427924.aspx.

Extending SharePoint Menu Control

The ECM team has uploaded the source code for the AspMenu web control. This will allow us to extend the functionality of the menu controls on MOSS 2007. More info at http://blogs.msdn.com/ecm/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control-mossmenu-source-code-released.aspx.