1

how can I open list items in search results page in modal dialog box? I have found some articles for SharePoint 2010 but not for SharePoint 2013.

Can anyone help me? Thanks a lot.

1

I made a hover panel by myself with an custom action.

After clicking that, a NewForm from another list will open up in an modal dialog.

Maybe this snippet will help you:

<div class="ms-srch-hover-action">
<a class="ms-calloutLink ms-uppercase" href="javascript:void(0)" onclick="javascript:SP.UI.ModalDialog.showModalDialog({ url: 'https://contoso.sharepoint.com/helplist/NewForm.aspx?ID=_#= ctx.CurrentItem.ListItemID =#_', title: '_#= ctx.CurrentItem.Title =#_' }); return false;" onmouseover="javascript:this.style.cursor='pointer';">Help</a>                
</div>
0

This can be done by editing XSLT of 'Search Core Results webpart' uses.

1 Edit the page 2 Edit the Search Core Results webpart 3 Expand the Display Properties section 4 Uncheck "Use Local Visualization" 5 Click on XSL Editor (and let the fun begin!)

Now,We need to modify the xsl. so that all search results that have a 'contentclass' that includes STS_ListItem will open in a modal dialog.

To do this, you'll need to edit the Result template ().

  1. This template starts off with a statement.
  2. Just after the block, remove the link tag :

    <a id="{concat($currentId,'_Title')}">
    <xsl:attribute name="href">
      <xsl:value-of  select="$url"/>
    </xsl:attribute>
    <xsl:attribute name="title">
      <xsl:value-of select="title"/>
    </xsl:attribute>
    <xsl:choose>
      <xsl:when test="hithighlightedproperties/HHTitle[. != '']">
        <xsl:call-template name="HitHighlighting">
          <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="title"/>
      </xsl:otherwise>
    </xsl:choose>
    

3.Replace it with the below markup

<xsl:choose>
    <xsl:when test="contains(contentclass, 'STS_ListItem') and not(contains(contentclass, 'STS_ListItem_DocumentLibrary'))">
        <style>.OnHover:Hover{cursor:pointer;}</style>
        <div id="{concat($currentId,'_Title')}" onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$url}')" class="OnHover">             
            <xsl:choose>
             <xsl:when test="hithighlightedproperties/HHTitle[. != '']">
              <xsl:call-template name="HitHighlighting">
               <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" /> 
              </xsl:call-template>   
             </xsl:when>
             <xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise> 
            </xsl:choose>
        </div>
    </xsl:when>
    <xsl:otherwise>
        <a id="{concat($currentId,'_Title')}">
            <xsl:attribute name="href">
              <xsl:value-of  select="$url"/>
            </xsl:attribute>
            <xsl:attribute name="title">
              <xsl:value-of select="title"/>
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="hithighlightedproperties/HHTitle[. != '']">
                <xsl:call-template name="HitHighlighting">
                  <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="title"/>
              </xsl:otherwise>
            </xsl:choose>
        </a>
    </xsl:otherwise>
</xsl:choose>
  1. Close the XSL Editor.
  2. Save the webpart's properties
  3. Refresh the page to test it. If this solution was any help to you up vote. please vote answered if it answered you well.
  • I think this is for SP2010. Can you show me (screen shot) where i can found XSL editor in SP2013? Thanks – Dominik Divák Aug 24 '16 at 18:42

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.