Here, I'm going to describe how we can use Content Query Web Part to Style SharePoint List. Thus, assume we are having a SharePoint List called
Projects with the following fields.
As you already knew, the default look and feel would be like below:
Now I'm going to render this list in to format something like below:
First, you need to define some names for these place holders (yeh, I know this do not make any sense to you. But don’t worry, just do the step). Thus, I'm going to define these columns as follows:
- Title –>
- Logo –>
- Project Summary –>
- Project Description –>
Now you want to define an XSL Style Sheet using these names. Therefore, I'm going to use
<table> to layout the list item as below:
<xsl:value-of select="@MyTitle" /></h3></td>
<xsl:value-of select="@MyLogo" />
Here, I used XSLT to position the content inside my HTML tags. There are few attributes which are mandatory in this section.
match should have equal names.
name =’X’ match=Row[@style=’X’]
mode = ‘itemstyle’
Now you have created XSLT which can be given as a list style in the SharePoint.
Here, we are going to put XSLT to the SharePoint.
First, you need to open the SharePoint designer with the particular site. Then, navigate to All Files and Style Library.
Here, you can see many folders inside. Now you have to go to XSL Style Sheet Folder.
Now you can see XSL files which are used by SharePoint to render its content. Here we are using ItemStyle.xsl for enabling custom rendering.
Thus open this XSL file and put your XSL (when we created in step two) in the bottom of the XSL as follows:
Now the difficult things are over.
- Add a Content Query Web Part:
- Then go to edit web part and browse your list (here our list is Our Projects):
- Then go to presentation section and go a little bit down. You can see style drop down.
- Wow... now you can see your style.
- Ok, then select your custom XSL (here
- When you select, you can see something like below:
- Now you need to put actual list column names to these text boxes as follows. (
Title column should use with the scope):
- Then click ok to Save. Now everything is ok. You can see your new list rendering now.
Happy SharePoint! :)