CODEDIGEST
Home » Articles
Search
 

Technologies
 

Sponsored links
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
How to add content to SPList Item view form?

By Shai Petel
Posted On Jan 15,2009
Article Rating:
Be first to rate
this article.
No of Comments: 0
Category: Sharepoint
Print this article.

How to add content to SPList Item view form?

By Shai Petel, VP R&D, KWizCom Corporation

 

The scenario: You have a list of customers and you want to add more information on the view item form (same goes for any other type of list).  For example:



I am sure many other SharePoint implementers have experienced this need…  Basically the desire is that when viewing an item on our list we want to see additional information like:
* Results on that customer from goggle on an iframe
 *Stock information for that customer
 *Information from an external system - showing in a frame that gets the customer ID in query string
Etc. etc. …

So what do we do?

The first thing is to remember that the list forms (edit, new and display) are actually normal web part pages, with one web part by default.

Adding web parts to your form is fairly easy. Simply add this to the query string of the form and you'll go into edit mode of your page:
&ToolPaneView=2



Another way is to paste this into your address bar:
javascript:MSOLayout_ChangeLayoutMode(false)

True, you can use SharePoint Designer instead - but this is much easier and involves nothing more than your browser...

Now that you got into edit form of your current item - you can add any web part you want!

Inside your web part code - you can make use of the SPContext.Current.Item to get the current item that is being loaded to the form and use it to render whatever you like.

But wait! There's an even better way!

I recently created a new product called "Current Item Property" that does exactly this and more…

By adding it to a list item form or to a WCM publishing page (or to a web part page in a document library for that matter) you will be able to do almost anything you wish.


How does it work?
2 simple properties of the web part:
First - allows you to specify what fields from the current item you want to use
Second - allows you to choose how to format that information in C# syntax (using {0},{1} etc).

After you set up the information you want - this web part can either send it by connection to another web part to use (like RSS viewer as the RSS feed url) or can simply write it to the page (when you want to create HTML from the information, or writing an iframe with changing URL).

So - lets go over what can be done with this tool, illustrating it's capabilities with a few examples from the customer I created this for:

We are starting with a simple list:




1 - Showing RSS information for partner

- Create a field in the list called "Stock", and set the stock ID for each partner
- Add the "Current Item Property" web part to the page



- Set it to use "Stock" field
- Set the format to a RSS URL: http://finance.yahoo.com/rss/headline?s={0}



- Add an RSS Viewer to the page


- Connect the two web parts using the RSS viewer "Get RSS URL" connection


Done!

2 - Showing Stock information for customer

- Create a field in the list called "Stock", and set the stock ID for each partner
- Add the "Current Item Property" web part to the page
- Set it to use "Stock" field
- Set the format to the iframe: <iframe style="WIDTH: 400px; HEIGHT: 150px" src="http://ichart.finance.yahoo.com/t?s={0}" frameborder="0"></iframe>


- Check the property "Show Content"


Done!

 

3 - Showing Google search results for issue

- Add the "Current Item Property" web part to the page
- Set it to use "Title" field
- Set the format to the iframe: <iframe style="WIDTH: 400px; HEIGHT: 150px" src="http://www.google.com/search?q={0}" frameborder="0"><iframe>
- Check the property "Show Content"
Done!


Using this method, it took me all of five minutes to add more content to the list items!

The product was released in October and can be found at: http://www.kwizcom.com/ProductPage.asp?ProductID=929&ProductSubNodeID=930

 

 

Similar Articles