How to open Content Query Web Part Item in Modal view popup? RRS feed

  • Question

  • How to open Content Query Web Part Item in Modal view popup?


    Please help !!!

    Friday, February 18, 2011 9:26 PM


All replies

  • Hi, what about to create a page with just the Content Query Web Part within? Then you can create a link to this page from another page using something like this:

    <script type="text/javascript">
    function OpenDialog(strPageURL) {
      var dialogOptions = SP.UI.$create_DialogOptions();
      dialogOptions.url = strPageURL;
      autoSize: true,
    return false;
    <a href="/Pages/CQWP.aspx" onclick="return OpenDialog('/Pages/CQWP.aspx');">Open CQWP</a>

    / Christian

    Blog: chrisstahl.wordpress.com Twitter: @Cstahl
    • Edited by Christian Stal Sunday, February 20, 2011 4:06 PM added codeblock
    • Marked as answer by Tech-Fun Tuesday, February 22, 2011 1:11 AM
    Sunday, February 20, 2011 4:03 PM
  • As an alternate way - I have implemented the solution described at http://www.aaune.org/wiki/index.php?title=CQWP_Direct_link_to_Editform

    successfully. What I like is the added portability.


    CQWP Direct link to Editform


    To link a title to the Edit form from CQWP you'll first have to edit the ContentQueryMain.xsl:

    I just copied the OuterTemplate.GetSafeLink and changed the Action to editform, and changed the name to OuterTemplate.GetEditLink.

    <xsl:template name="OuterTemplate.GetEditLink">
        <xsl:param name="UrlColumnName"/>
        <xsl:if test="$UseCopyUtil = 'True'">
          <xsl:value-of select="concat($RootSiteRef,'/_layouts/CopyUtil.aspx?Use=id&amp;Action=editform&amp;ItemId=',@ID,'&amp;ListId=',@ListId,'&amp;WebId=',@WebId,'&amp;SiteId=',$SiteId,'&amp;Source=',$Source)"/>
        <xsl:if test="$UseCopyUtil != 'True'">
          <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
            <xsl:with-param name="UrlColumnName" select="$UrlColumnName"/>

    Now you need to set up your ItemStyle.xsl to use the template.

    First make the variable, can be named whatever, in this example I used SafeLinkEditUrl.

    <xsl:variable name="SafeLinkEditUrl">
      <xsl:call-template name="OuterTemplate.GetEditLink">
       <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>

    Finally you can use it with xsl:value-of:

    <a href="" title="{@LinkToolTip}" 
       onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkEditUrl}');return false;">
         <xsl:value-of select="$DisplayTitle"/> 

    • Proposed as answer by phettz Thursday, October 27, 2011 12:17 PM
    Wednesday, August 24, 2011 2:12 AM