Search This Blog

Tuesday, October 20, 2009

[Tutorial] Customize Content Query Webpart Item Style in XSLT – DateTimeFormat

Here share with you on how to customize the Item Style in itemStyle.xsl...

Step 1 : Open SharePoint Designer and then click on “File” to “Open Site” for the portal.

image 

image

Step 2 : After you have success open the portal content, a tree-view “Folder List” for the portal content will be display on left hand corner.

image

Step 3 : Double Click on “Style Library” > “XSL Style Sheets” > “ItemStyle.xsl”. All Item Style now listed out on your right hand corner.

image

Step 4 : Assume you wan to poll out Site Column “EventDate” and “EndDate” from you content.you can check internal name for the Site Column for example “Start Date” by right click property of the Site Column.

image

P.S. More way get to know Internal Site Column value please visit Customizing the Content Query Web Part and Custom Item Styles.

Step 5 : Sample Code to show “Event Date” and “EndDate”. Before that please ensure on the top you have already include

(xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime") in your “<xsl:stylesheet>”

Item Style

Step 6 : After you have finished included all code and now you can add a “Content Query Web Part” to use this item Style.

Click http://atquestdemo.blogspot.com/2009/10/practice-apply-custom-item-style-for.html to see how to use item style for Content Query Web Part.

Step 7 : Note that you would not get the output correct unless you do something on the Web Part. Therefore, you have to “Export” it and make changes through “Note Pad.exe

image

Step 8 : After you have success open it look for “CommonViewFields” and start addin the “Internal Site Column” value follow by “data type”.

image

Step 9 : Import the edited web part back to the site and you able to view the whole style format.

Click here to see how to import Webpart!

image

Additional Notes

  • Date Time Format Style

image

image

image

image

image

Reference from : Csharp-example : String Format for DateTime [C#]

  • Content Type for Site Columns

image

Reference from : Heathersolomon : Customizing the Content Query Web Part and Custom Item Styles

No comments:

Post a Comment