Tuesday, September 25, 2007

Tip: Customising Content Query Web Part XSL

There has been a plethora of articles on customising the XSL of a content query web part, some even from Microsoft ;)

I wont run over the step by step process but just add to this wealth of information a little tip on making the XSL a little easier to manage and support.

As we have learnt the XSL used to render the output is split into 3 files;
ContentQueryMain.xsl
ItemStyle.xsl
Header.xsl

All three of these files will exist in the '\Style Library\XSL Style Sheets\' library of a site created using the Publishing template.

Instead of modifying these files it is possible to create your own custom XSL style sheets for each and tell your CQWP to use these by specifying the properties as follows;

HeaderXslLink = "/Style Library/XSL Style Sheets/customHeader.xsl"
ItemXslLink = "/Style Library/XSL Style Sheets/customItem.xsl"
MainXslLink ="/Style Library/XSL Style Sheets/customMain.xsl"

44 comments:

Alex Ureña said...

Hi,

Do you know why when I set the ItemXslLink or MainXslLink programmatically, there's an error like this:

Object reference not set to an instance of an object.
at Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart.MakeSiteRelativeUrl(String xslServerRelativeUrl)
at Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart.SetXSLLink()
at Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart.set_HeaderXslLink(String value)

I'm using SPLimitedWebPartManager to get the webparts in the page.

Thanks for your help.

Lee Marriage said...

Alex,

It appears you don't have a valid instance of a CQWP, check that you can set other properties on the object. Let me know if problem persists.

Lee

Alex Ureña said...

Hi Lee,

Exactly as you told me, the problem was an instance of an object, specifically the HttpContext. I just set the property with a new instance, and everything works fine now!!

Thanks for your help,

Alex

Anonymous said...

Hello,

If I don't have access to those sysetm folders can export the webpart and then modify those properties (itemxsllink, MainXslLink, etc.) to point to xsl files that I place in a shared documents folder within my site?

Thank you.

Anonymous said...

Can you tell me where am i supposed to modify these properties so that the content query web part will automatically recognize the custom xsl style sheets?

Lee Marriage said...

Hi Avanti - You'll need to modify the properties of the CQWP that you have included in the page. To do this you will need to export the Web Part, save the .webpart file locally, then open it up and find the neccessary properties. Once you have set the properties save the .webpart file and then import it back into the page.

Anonymous - Yes you can point the files to any valid url that users will have access to.

Rgds,
Lee

Anonymous said...

Thanks Lee..!That worked for me.. But i wanted to try some further customization with the Content query web part. Without exporting the web part, how can i make the web part, recognize my custom stylesheet? Even though i changed it in sharepoint designer, it did not recognize it and was still using the default style sheets..

Anonymous said...

Hi,

I've just developed a new custom Content Query Web Part.
I would like to use its default style sheet. It is now not working, unless i put together my custom ContentQueryWebPart and the original contentquerywebpart in one page.

Do you know how to fix this issue?
i've put the itemxsllink as your instructed and also add them up in my coding.

Any help would be appreciated.

Maulee Vadi said...

how do you use Httpcontext in your console app to update the ItemXSLLink, MainXSLLink and HeaderXSLLink?

Maulee Vadi said...

how do you add httpcontext within your code snippet of SPLimitedWebPartManager to update ItemXSLLink, MainXSLLink, HeaderXSLLink?

Anonymous said...

It's actually a nice and helpful piece of info. I'm glad that you
just shared this useful info with us. Please keep us up to date like this.
Thanks for sharing.
Take a look at my webpage ... click through the next post

Anonymous said...

buy tramadol online tramadol buy - there generic form tramadol

Anonymous said...

buy tramadol online tramadol ingredients codeine - vicodin vs ultram tramadol

Anonymous said...

generic xanax xanax maximum dosage - taking 2mg xanax

Anonymous said...

generic xanax xanax 7.5mg - xanax mayo clinic

Anonymous said...

buy tramadol online has bought tramadol online - buy tramadol online no prescription next day delivery

Anonymous said...

carisoprodol 350 mg carisoprodol buy online no prescription - soma carisoprodol tablets 250

Anonymous said...

order cialis online no prescription legal to buy cialis online - cialis price with prescription

Anonymous said...

buy tramadol online cheap tramadol usa - need to purchase tramadol

Anonymous said...

cialis online buy cialis online no prescription usa - cialis online buy

Anonymous said...

xanax cheap xanax valium high - buy xanax online prescription

Anonymous said...

cialis 20mg generic cialis effectiveness - buy cialis online nz

Anonymous said...

Write more, thats all I have to say. Literally, it seems
as though you relied on the video to make your point.
You obviously know what youre talking about, why throw away your intelligence on just posting videos to your
blog when you could be giving us something enlightening to read?



Visit my blog post :: nikon digital camera

Anonymous said...

http://landvoicelearning.com/#30896 tramadol information - can buy tramadol usa

Anonymous said...

http://buytramadolonlinecool.com/#96430 buy tramadol cheapest - buy tramadol cod personal check

Anonymous said...

20000 :) buy effexor - effexor cost http://www.effexorfastorder.net/#effexor-cost , [url=http://www.effexorfastorder.net/#buy-venlafaxine ]buy venlafaxine [/url]

Anonymous said...

http://landvoicelearning.com/#63987 cheap tramadol overnight shipping - cheap tramadol overnight delivery

Anonymous said...

http://buytramadolonlinecool.com/#59473 order tramadol online no rx - tramadol 50 mg compared to percocet

Anonymous said...

http://landvoicelearning.com/#63987 tramadol for dogs with arthritis - tramadol 50 mg headache

Anonymous said...

buy tramadol tramadol overdose mg - tramadol 50mg ndc

Anonymous said...

buy tramadol online tramadol hcl 50 mg strength - buy cheap tramadol cod

Anonymous said...

http://ranchodelastortugas.com/#93851 1mg xanax is equal to how much valium - kinds xanax bars

Anonymous said...

alprazolam xanax xanax xr withdrawal side effects - white round pill generic xanax

Anonymous said...

xanax no rx xanax and alcohol overdose symptoms - xanax without doctors prescription

Anonymous said...

Judging from your way piddle footprint when it happens to your skin. Saks Twenty percent avenue's Elderly style conductor Gina Kelly says it's atrocious that everyone else is being set. www.kasper-suits.net/ [url=http://kasper-suits.net/]kasper suits petite[/url] [url=www.kasper-suits.net/]kasper dresses[/url] [url=http://kasper-suits.net/]kasper suits online[/url] They actually Opt to buy them fashion. kasper womens suits kasper suits for women Fabrics for the 2013 Prosperous Globes red carpet at the ticker trueness fashion design show during Mercedes-Benz fashion design workweek presentation this Friday 22nd March, featuring bold chevron & lechatelierite embellishments. spray on the Continue of a Wedding fashion trend. Billabong's Fashion argument quite advantageously Together, Henderson and Lydia's kinship developed and he hung it out for a man?

Anonymous said...

Your article featurеs established helpful to me. It’s eхtгemely usеful аnd you're certainly very experienced in this region. You get popped my own face to varying opinion of this specific topic together with intriguing and strong written content.
Here is my webpage - viagra

Anonymous said...

Youг article offеrs veгіfіeԁ
neсesѕarу to me. It’s quite еԁucatіonal
аnd you're certainly quite well-informed of this type. You have exposed my personal eyes to different opinion of this kind of topic along with interesting and reliable content material.
My web page :: http://www.zartac.com/tiki-index.php?page=UserPagenealzw

Anonymous said...

Informative article, just what I was looking for.

Look into my web-site fastest way to lose weight

Anonymous said...

Hello! Do you know if they make any plugins to safeguard against hackers?
I'm kinda paranoid about losing everything I've worked hard on.
Any suggestions?

Also visit my web blog: joshua pellicer youtube

Anonymous said...

cheap tramadol online tramadol online pharmacy - buy tramadol overnight shipping

Anonymous said...

Thanks for sharing your info. I really appreciate your efforts and I
will be waiting for your next post thanks
once again.

Here is my web-site - slc-wireless.com

Anonymous said...

Thankfulness to my father who stated to me concerning this weblog, this web site is actually remarkable.


Look at my web blog ... www.pussyxxx.org

Anonymous said...

At this time I am going to do my breakfast, when having my breakfast coming over
again to read other news.

Also visit my blog post; xxx-fuck.net

Anonymous said...

This design is spectacular! You obviously know how to keep a reader entertained.
Between your wit and your videos, I was
almost moved to start my own blog (well, almost.

..HaHa!) Wonderful job. I really loved what you had
to say, and more than that, how you presented it.
Too cool!

Also visit my blog: http://handjob-teens.com/homegrownvideos-big-boo