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

Using C#, I am inserting web parts into web part zones programmatically and styling them. More specifically, I'm inserting CQWP's and assigning XSLT files to them.

I'm now wanting to allow users to insert their own CQWP's into the web part zone's through the UI and make available the same styles.

I can obviously insert the CQWP into the zone, but under Item Styles I don't see the same templates as what are defined in my XSLT file, which I can see for the CQWP's that were inserted programmatically.

Why are none of the XSLT templates available to me under the available styles for these CQWP's?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you insert the default CQWP throught the UI it will automatically use the ItemStyle.xsl from the Style Library by default.

In order to do what you want to do, you'd have to create your own CQWP and add some EditorPart or Toolpart to it in which you include the functionality to be able to choose whatever XSLT file for itemstyles you want.

Here's an example on how to extend the CQWP (aka. create your own).

Here's an example on how to add your own EditorPart/ToolPart to the webpart.

Hope it helps :)

share|improve this answer
    
Thanks a lot Daniel, appreciate your answer. I'm disappointed this is the only way to achieve this but I'll begin reading up on extending the CQWP nevertheless. Thanks again. –  DeeMac Apr 29 '13 at 9:49
1  
@DeeMac It's either this solution or you're going to have to add your custom itemstyles in the ItemStyle.xsl file in Style Library. That way you don't have to create your own XSL files and include them seperately. –  Daniel Ziga Apr 29 '13 at 10:40
    
Given the fact we need to keep these files separately, I've implemented your first solution. Thanks again mate, appreciate it. –  DeeMac Apr 29 '13 at 11:18
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.