Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 
>>> >> > Make the most of SQL Server Integration Services Script Components < << <<<
 

How to Create a Reusable Custom Style for the Content Query Web Part


By:   |   Read Comments   |   Related Tips: > Sharepoint

Problem

Content Query Web Parts are used to fetch data from different sites in a web application. This web part can be used for various purposes like displaying the latest news or latest events. There can be situations that, despite of having different purposes, the Content Query Web Part might need a uniform data display style.

Solution

The solution is to centralize a style that can be reused.

For our case, we have created two lists: "Movies" and "Shows". These lists will contain basic information like movie or show name, description and their release or event dates.

movies
shows

Next, we have used a multiple Content Query Web Part on a single page to view data from both lists and applied a default presentation style on both.

movies

To create a new custom style, open the site in SharePoint Designer. Go to Style Library -> XSL Style Sheets -> Itemstyle.xsl. "Itemstyle" contains templates that define how to display an item. We have created a very basic custom style named "MyCustomStyle" as shown in the image.

name

After saving the "itemstyle", go to page in a web browser and click edit page. Select the Movies Content Query Web Part and open the tool pane. Go to Presentation -> Styles -> Item Style dropdown.

query

Click on the dropdown and we can see the custom style that we have just defined in itemstyle.xsl.

presentation

Select the style and Click Apply and after that OK.. Now you can see the changes in the Movies Content Query Web Part.

movies

In order to reuse it in the Shows Content Query Web Part, perform the same steps of selecting the style that we have performed on the Movies Content Query Web part.

rain
Next Steps
  • Use Custom Style to define different display styles


Last Update:


next webcast button


next tip button



About the author
MSSQLTips author Siddharth Mehta Siddharth Mehta is an Associate Manager with Accenture in the Avanade Division focusing on Business Intelligence.

View all my tips





Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools