Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to add an extra template to ItemStyle.xsl using a feature deployment - any idea how to add things to that file programmatically?

share|improve this question
add comment

1 Answer

Actually it might be easier (also best practice - to avoid overrides by CU, Service Packs, etc.) to have a copy of that file with your own style already in, and provision it via a Module as part of your feature!

CQWP is using multiple XSL files (3 actually) stored in the Style Library at the site collection level. You can of course chose to deploy your own in the same location (by creating a folder) and use a Module (I am assuming here the use of Visual Studio 2010 to create a solution package) or by simply copying such files manually (SPD 2010 is also a good option).

As a last step is to Export your already configured CQWP and replace the page in the XML to point to the new location (using site collection relative URLs - without host name address, etc.). Once change is performed you would to simply use "Import Web Part" in the page where needed and go from there, but this time the Web part actually points to your own. Now you only need to update the file (via SharePoint Designer 2010 directly) and refreshing should read your latest change instantly.

As a word of caution: if not changes are observed in your CQWP it means something is wrong and actually SharePoint will default to original settings, therefore your CQWP will not show other styles and it will use Default ones.

share|improve this answer
    
Can you elaborate on that? A more detailed example would be very helpful - I am fairly new to SharePoint –  Andrey Oct 12 '12 at 13:35
    
please see updated response! –  C. Marius - MVP Oct 12 '12 at 15:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.