Sharepoint Insight by Namwar Rizvi

Sharepoint Tips, Tricks and inside knowledge from real world experience by Namwar Rizvi

Archive for the ‘Customization’ Category

Reverse Engineer the Schema of any List in SharePoint

Posted by namwar on December 26, 2009


If you have ever designed a custom list then you may already felt the pain of creating the schema of it and writing the whole CAML. Sometimes, we just need to enhance an already existing list by creating our own custom list for which we want to copy the existing schema and do the necessary changes.

You can retrieve the schema of any list by using the owssvr.dll call from your browser. Following is the syntax

http://<YourServer>/_vti_bin/owssvr.dll?Cmd=ExportList&amp;List=<YourListGuid>&#8221;

By replacing the Server and List GUID in above url will return you the XML Schema of the list.

To make thing easier, I have created a Feature to add a custom action in Settings menu called “Display Schema“, Click it and you will get the schema of the list.

Steps to create the feature:

1. Create a new folder called “DisplaySchema” in Features folder.

2. Create Feature.xml file and paste the following code

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="{A66E6CBA-8EA1-4c28-B233-52B3D7FF352B}"
    Title="Display List Schema"
    Description="This feature adds a custom menu item in Settings menu to display List Schema"
    Version="1.0.0.0"
    Scope="Site"
    xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="Elements.xml" />
  </ElementManifests>
</Feature>

3. Create Elements.xml file and paste the following code

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- List Toolbar Settings Menu Dropdown -->
  <CustomAction Id="DisplayListSchema"
    RegistrationType="List"
    GroupId="SettingsMenu"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="1000"
    Title="Display Schema"
	Description="Displays schema of the list">
    <UrlAction Url="~site/_vti_bin/owssvr.dll?Cmd=ExportList&amp;List={ListId}"/>
  </CustomAction>
</Elements>

4. Install the feature by using stsadm command line tool.
5. Activate it.
6. Navigate to any list, Document Library, Tasks list etc. and click Settings, and then click Display Schema.
You will get the schema of that list. Copy it and enjoy!

Advertisements

Posted in Customization, Feature, Solutions, Tips, Tools | Tagged: , , , | 2 Comments »

List of all possible Content Place Holders of SharePoint

Posted by namwar on December 21, 2009


For a handy reference I am listing all possible Content Place Holders in SharePoint pages. This list is obtained from here

Content placeholder Description
PlaceHolderBodyAreaClass Additional body styles in the page header
PlaceHolderBodyLeftBorder Border element for the main page body
PlaceHolderBodyRightMargin Right margin of the main page body
PlaceHolderCalendarNavigator Shows a date-picker for navigating in a calendar when a calendar is visible on the page
PlaceHolderFormDigest The “form digest” security control
PlaceHolderGlobalNavigation The global navigation breadcrumb
PlaceHolderHorizontalNav Top navigation menu for the page
PlaceHolderLeftActions Bottom of the left navigation area
PlaceHolderLeftNavBar Left navigation area
PlaceHolderLeftNavBarBorder Border element on the left navigation bar
PlaceHolderLeftNavBarDataSource Data source for the left navigation menu
PlaceHolderLeftNavBarTop Top of the left navigation area
PlaceHolderMain Main content of the page
PlaceHolderMiniConsole A place to show page-level commands, for example, WIKI commands such as Edit Page, History, and Incoming Links
PlaceHolderNavSpacer The width of the left navigation area
PlaceHolderPageDescription Description of the page contents
PlaceHolderPageImage Page icon in the upper-left area of the page
PlaceHolderSearchArea Search box area
PlaceHolderSiteName Site name
PlaceHolderTitleAreaClass Additional styles in the page header
PlaceHolderTitleAreaSeparator Shows shadows for the title area
PlaceHolderTitleBreadcrumb Main content breadcrumb area
PlaceHolderPageTitleInTitleArea Page title shown immediately below the breadcrumbs
PlaceHolderTitleLeftBorder Left border of the title area
PlaceHolderTitleRightMargin Right margin of the title area
PlaceHolderTopNavBar Top navigation area
PlaceHolderUtilityContent Extra content at the bottom of the page
SPNavigation Empty by default in Windows SharePoint Services 3.0. Can be used for additional page editing controls.
WSSDesignConsole The page editing controls when the page is in Edit Page mode (in the browser, click Site Actions, and then click Edit Page)

UPDATE: An excellent visual reference to above mentioned Content Place Holders can be found here

Posted in Customization, Tips | Tagged: | Leave a Comment »

Displaying only Year in SharePoint Calculated Column

Posted by namwar on November 26, 2009


I wanted to display just the year of a DateTime column of SharePoint. I created a calculated column and set the formula to Year([MyDateTimeColumn]). The result I got was 2,009 ; 2,008 etc. which offcourse incorrect for year. After searching through internet, I found a good article solved my problem.

The correct formula is TEXT(YEAR([MyDateTimeColumn]),”000″)


Posted in Architecture, Customization, Solutions, Tips | Tagged: , , , | Leave a Comment »

Custom Edit Form for SharePoint Lists

Posted by namwar on October 21, 2009


If you want to set a custom edit form to your Sharepoint List then please make sure you follow these Golden Rules as correctly suggested by Hugo in a SharePoint news group.

  1. NEVER delete or rename the default pages…
    when you want to create a new EditForm.aspx it’s best to copy it to
    another file and then edit the original one (without renaming it and
    without reassigning the supporting files)…
  2. DON’T ever delete the webparts that exist.
    It’s better to hide them and create new ones “side-by-side”.

These rules are real time savers and I will highly encourage every reader to follow them.

Posted in Customization, Errors, Tips | Tagged: , , , | 1 Comment »

Microsoft SharePoint Designer is now Free !

Posted by namwar on April 7, 2009


SharePoint Designer Team at Microsoft has announced at its blog here that Anyone can use SharePoint Designer as a free tool. This is really a step in right direction and will help SharePoint community to build better user experiences. 

You can download the SharePoint Designer from here

Posted in Customization, Tools | Tagged: , , , , | Leave a Comment »

Launch Office Application from SharePoint Portal Page

Posted by namwar on February 26, 2009


Business Problem:

    One of my client wanted to have links on main portal to launch Microsoft Office key applications i.e Word, Excel, Power Point and Outlook directly by clicking on a link at portal page.

Solution:

I searched the net and find a nice solution here It is a small piece of JavaScript code which you can put in CEWP and use it on your portal page. I added some formatting and relevant icons against the office applications and wraps it up in a webpart dwp file. After importing this web part on your page, you will get something like this:

launchofficeapplication1

You can download the dwp file from here

Posted in Customization, JavaScript, Uncategorized | Tagged: , , , , | 3 Comments »

List of SharePoint URL tokens

Posted by namwar on December 1, 2008


Following is a list of tokens available in Sharepoint to use in your URLs. Be aware that Sharepoint only replaces the value of a token once for a given string, so if you have used the same token twice, second occurance will not be replaced by the token value. I will post a solution to do it in my next article:

~site – Web site (SPWeb) relative link.

~sitecollection – site collection (SPSite) relative link.

In addition, you can use the following tokens within a URL:

{ItemId} – Integer ID that represents the item within a list.

{ItemUrl} – URL of the item being acted upon. Only work for documents in libraries. [Not functional in Beta 2]

{ListId} – GUID that represents the list.

{SiteUrl} – URL of the Web site (SPWeb).

{RecurrenceId} – Recurrence index. This token is not supported for use in the context menus of list items.

Posted in Architecture, Customization | Tagged: , | 4 Comments »

How to get raw XML of Sharepoint Search Core Results Web Part?

Posted by namwar on September 12, 2008


If you are like me and trying to customize the search result presentation in SharePoint then you must have faced the issue of customizing the XSL of Sharepoint Search Core Results Web Part. You can customize the XSL by using SharePoint Designer or any other WYSIWYG XSL editor, if you know the raw XML returned by Search.

To get the raw XML click XSL Editor button of Search Core Results web part and replace the already provided XSL with the following

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; >

<xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes” />

<xsl:template match=”/”>

<xmp><xsl:copy-of select=”*”/></xmp>

</xsl:template>

</xsl:stylesheet>

Posted in Customization | Tagged: , , , | Leave a Comment »