Showing posts with label xslt. Show all posts
Showing posts with label xslt. Show all posts

Thursday 15 July 2010

Deploying resources using features

Overview: Feature deployment has changed in SP2010 from MOSS. In MOSS we added files to the 12 hive and deployed them via a feature. In SP2010 the feature is package slightly differently and is marginally easier to create using VS2010 because of the tools. I have VS2010 and the CKSDev tools installed.

Steps to add an xslt file to your style library using a feature in SP2010:
1.> In VS2010 create a new Element;
2.> Under the element add and xslt, change the "Deployment Type" property;
3.> Move the elements to "Items in the Feature" default is "Items in the Solution";
4.> Modify the elements.xml file;

5.> Ensure the itemStyleCustom.xsl exists in the Xsl Style library.

Wednesday 14 July 2010

SP2010 CQWP customisation

Overview: Content Query Web Part (CQWP) in SP2010 is similar to in MOSS. This post walks thru using the CQWP to display a custom list and custom columns while outputting custom html via a custom xslt.
CQWP (need the publishing feature enabled, this creates the styles library and add the CQWP) by default uses the xslt /Style Library/XSL Style Sheets/ItemStyle.xsl.

Steps:
  1. Don't write over ItemStyle.xsl as this si supplied by SP2010 OOTB. Rather create a new xslt and put it into the styles library. Build up the xslt, I based my file on the itemstyle.xsl file, see rules for getting the output you are looking for using How to: Customize XSL for the Content By Query Web Part
  2. Custom xslt formatting, I always add the following code in case I want to see what the available fields are:
  3. Deploy the custom style sheet via a feature.
  4. Create a new Custom list called "Pets" and add columns for Title, Age & Status (choice):
  5. Edit your custom xslt to display for "Pets" as shown below:
  6. Add a new CQWP to your page. Configure it to display items from your new list (Pets).
  7. Change the "Presentation" section, "Item Style" to Show "Pets". Apply the Changes:
  8. CQWP displays as:
  9. Edit the CQWP "Age" property to "Age"
  10. Edit the CQWP "Age" property to "Status"

    Sunday 13 June 2010

    Using embedded jQuery in xslt for SharePoint

    Problem: A lot of web parts (WP) use xslt to create the html user interface(UI). You need to escape characters in order to get jQuery to work.
    Initial Hypothesis:
    Can use a Content Network Content copy of jQuery, has the advantage of being up-to-date and may be cached in user browser already. Issue is that may not be trusted or available on an Intranet.
    jQuery file/s should be embedded in the master page (this should be activated in a feature).
    Inside the xslt add the jQuery to perform your custom actions as shown below that does not escape characters: