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 would like to customise the Content Query Webpart like i normally do with DWP but i know its a different approach.

All i want to do is to get the title name and turn it into a link and when you click the title link i want it come up with a a custom page that i would create and pass some querystring parameters to it.

Something like this

e.g

<a href="#" onclick="openDialog('/sites/Sample/Pages/GMComms.aspx?ID={@ID}','{$title}'); return true "><xsl:value-of select="@Title"/></a>

the openDialog is the

SP.UI.ModalDialog.showModalDialog();

Any ideas would be appreciated.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

In that case you'll have to either modify or create a new XSLT Template in the ItemStyle.xsl file, which you find in the /Style Library/XSLT Style Sheets/ItemStyle.xsl

In the template you can insert javascript as follow:

<script language="javascript" defer="true">
  <xsl:comment>
    <![CDATA[
      $(document).ready( function() {
        // logic here

        // Example to include XSLT variables
        $('#AnchorID').click(function () {
          var url = $(this).attr('href');
          SP.UI.ModalDialog.openModalDialog(url,]]> <xsl:value-of select="$title"/> <![CDATA[);
        });
      });
    ]]>
  </xsl:comment>
</script>
share|improve this answer
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.