0

I have 6 fields that need to be displayed differently in list views. Normally, I would accomplish this by deploying a fldtypes_....xsl file to the hive. The problem here is that I cannot use farm solutions and I have no access to the hive. So I had to look for an alternative.

What I ended up doing was:

  • Create an .xsl file in the style library that contains the template for my field
  • Edit the XSL property of the list views with SPD to import my .xsl file and call the template for my custom fields

But this raises some issues:

  • The performance takes quite a hit. When a page has been loaded and I revisit, everything is fine. But 10 minutes later it will take a long time again (I assume things need to be compiled or cached)
  • I need to edit each view individually. So if my template needs to apply to a new field, I need to edit every single view I have out there to add a match for that field.
  • If someone creates a new view in a list, I need to open it up in SPD to modify the XSL

So I was wondering if anyone out there has done something like this before? Are there any easier / more efficient / more manageable ways of achieving this?

1

I have used custom XSLT files quite a bit and not noticed any significant performance issues. How are you applying the XSLT? I usually edit the web part properties in the browser and add a link to my XSL file under Miscellaneous -> XSL link.

You could try doing the same thing with a CQWP?

Either of the above would mean you only have to change the XSL in one place to impact all web parts that are using it.

  • That's interesting. When you reference an XSL file like that, do you have to include a lot of 'baggage', i.e. do you have to use a default .xsl and expand on it, or can it contain only your custom code? – Kenneth Van Coppenolle Aug 7 '13 at 8:51
  • It needs to be a stylesheet but can be as simple as you like. I have some XSL tutorials that go through this on my blog paylord.wordpress.com – Dave Paylor Aug 7 '13 at 8:53
  • Well, I managed to get the presentation to work just fine by using the XslLink property, but I ran into a but in SharePoint described <a href="glynblogs.com/2011/05/…>. Bottom line it's unfortunately not practical, even though it's easier to modify the XSL. Thanks anyway though. – Kenneth Van Coppenolle Aug 7 '13 at 13:00
  • Did you try the suggestion at the bottom of Glyn's blog post - about using an import? – Dave Paylor Aug 7 '13 at 20:54
  • I did, but it also messes up the ribbon controls. – Kenneth Van Coppenolle Aug 8 '13 at 6:32
1

Are you provisioning list definitions with a schema file in your sandbox solutions? If so you can edit the <View> elements in your schema file to include the Xsl you want to add to your view. Here is how you'd do it:

<Views>
 <View DisplayName="All Items".....>
  <Xsl>
    <![CDATA[<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"....
    (your xsl goes here)
    ]]>
  </Xsl>
</View>

Note that you need to wrap the XSL in a CDATA block. Prototype your list and view in SPD and then paste the customized XSL from SPD right into your list definition.

The advantage of this approach over your approach is that there is no longer any manual post-deployment step - the XSL is wrapped right into the solution.

And since the XSL is defined right in the view's schema there should be no performance penalty.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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