Answered Render result for CQWP ?

  • Monday, May 28, 2012 11:08 AM
     
     

    Hi all

    I have extended a Web Part class with :ContentBQuery, and in the code I find some values I want to present in the rendering og my custom content Query Web Part. I am having problems showing the values I find in code behind in the rendering of CQWP. 

    How can I show a value from code behind in my cuostm xslt ? 

    Any ideas or tips for me?

    Thanks

All Replies

  • Monday, May 28, 2012 11:16 AM
     
     

    Have a look at overriding ModifyXSLTArgumentList, this is where I usually inject values into the XSLT processing.

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webcontrols.contentbyquerywebpart.modifyxsltargumentlist.aspx

    Paul.


    Please ensure that you mark a question as Answered once you receive a satisfactory response. This helps people in future when searching and prevents the same questions being asked multiple times.

  • Monday, May 28, 2012 1:12 PM
     
     

    Hi Cimares

    Thanks for your tips. Do you have any samples ? :)

    Thanks

  • Monday, May 28, 2012 1:51 PM
     
     Answered Has Code

    Ok, well a good example is where I need to pass in the current LCID value for the current web for use in variations sites.

    protected override void ModifyXsltArgumentList(ArgumentClassWrapper argList)
    {
         base.ModifyXsltArgumentList(argList);
         argList.AddParameter("LCID",String.Empty,CurrWebLCID);
    }

    Note, once you've done this, it's made the value available int he XML, but you'll need to add the parameter to the top of your actual XSLT to make use of it.

    <xsl:param name="LCID"/>

    Hope this helps.

    Paul.


    Please ensure that you mark a question as Answered once you receive a satisfactory response. This helps people in future when searching and prevents the same questions being asked multiple times.

  • Friday, June 01, 2012 3:54 PM
     
     

    Thanks mate. 

    This worked like a charm. Just one additional thing to mention is that to show the rendering in the CQWP, you must write this in the itemstyle.xsl:

    <xsl:value-of select="$LCID"/>