XSLT for Display search result in box format. Copy this xslt in to Search Core Results webpart's XSL Editors Properties.
Search Result :
<xsl:stylesheet version="1.0" xmlns:wxsl="http://www.w3schools.com/w3style.xsl" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"> <xsl:output method="xml" indent="yes"/> <!--this tamplate is main tamplate wich calls dvt_1 and main root template of this xslt.--> <xsl:template match="/"> <style type="text/css"> <!-- .subDiv{width:308px; height:150px; border:1px solid Green; padding:5px; float:left;margin-left:5px;margin-top:5px;} .clearDiv{clear:both;}--> *{padding:0px; margin:0px;} body, html{font:normal 12px Arial, Helvetica, sans-serif; color:#000000;} .float_l{float:left;} .mainDiv{width:655px;} .contentBox{width:308px; min-height:122px; background-color:#f4f4f4; padding:5px; margin:0 0 5px 5px;} .contentBox h1{font:bold 14px Arial, Helvetica, sans-serif;color:#FFFFFF !important; padding-bottom:10px; padding-left:2px !important; } .Title{font:bold;background-color:#EEAA09;vertical-align:middle; padding-top:5px;} .Title a{color:#FFFFFF !important; text-decoration:none;} .contentBox a{text-decoration:none;} .contentBox .flotBox{overflow:hidden; color:#666666; font-size:12px; padding-bottom:5px; padding-left:2px !important; padding-top:5px; } .contentBox .flotBox .left{float:left;} .contentBox .flotBox .right{float:right;} .contentBox .norText{font:normal 12px Arial, Helvetica, sans-serif; color:#000000;} .contentBox .norText a{float:right; color:#0072bc; text-decoration:none; padding-left:2px !important;} .contentBox .clearDiv{clear:both;} </style> <script type="text/javascript"> function moreless(abc,fullText) { if(abc.innerText == "more>>") { div = abc.parentNode.getElementsByTagName('div'); div[0].innerText = fullText; abc.innerText = "<<less"; } else if(abc.innerText == "<<less") { div = abc.parentNode.getElementsByTagName('div'); div[0].innerText = fullText.substring(0,75); abc.innerText = "more>>"; } } function onDisplayItem(urlTest) { var options = { url: urlTest, autoSize:true, }; SP.UI.ModalDialog.showModalDialog(options); } </script> <xsl:call-template name="dvt_1"/> </xsl:template> <xsl:template name="dvt_1"> <xsl:variable name="dvt_StyleName">Table</xsl:variable> <xsl:variable name="Rows" select="/All_Results/Result"/> <table border="0" width="95%" cellpadding="4" cellspacing="2" id="ResultsTable" align="right"> <tr> <td> <xsl:call-template name="dvt_1.body"> <xsl:with-param name="Rows" select="$Rows"/> </xsl:call-template> </td> </tr> </table> </xsl:template> <!--this tamplate is used is body template which displys all recods it calles dvt1.rowview temp and dispalys all rows--> <xsl:template name="dvt_1.body"> <xsl:param name="Rows"/> <xsl:param name="count" select="2"/> <div class="mainDiv"> <xsl:for-each select="$Rows"> <xsl:variable name="Position" select="position() mod 2"></xsl:variable> <xsl:call-template name="dvt_1.rowview"/> <xsl:choose> <xsl:when test="$Position < 1"> <div class="clearDiv"></div> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:for-each> <div class="clearDiv"></div> </div> </xsl:template> <!--this tamplate is used to get site, sub site, site collection urls. from related links.--> <xsl:template name="SPWebUrl"> <xsl:param name="siteUrl" /> <xsl:param name="contentclass" /> <xsl:choose> <!--<!–- Check the content class to see if it is a document -–>--> <xsl:when test="$contentclass='STS_ListItem_DocumentLibrary'"> <!--<!– Get Document Library Url Name –>--> <xsl:variable name="DocLib"> <xsl:call-template name="StripSlash"> <xsl:with-param name="text" select="$siteUrl"/> </xsl:call-template> </xsl:variable> <!--<!– Remove the document library from the url –>--> <xsl:variable name="SPWebURLString" select="substring-before(concat($siteUrl, '/'), concat('/', concat($DocLib, '/')))" /> <xsl:value-of select="$SPWebURLString"/> </xsl:when> <xsl:otherwise> <!--<!– Get List Url Name –>--> <xsl:variable name="ListUrl"> <xsl:call-template name="StripSlash"> <xsl:with-param name="text" select="$siteUrl"/> </xsl:call-template> </xsl:variable> <!--<!– Remove the list name from the url –>--> <xsl:variable name="urlLists" select="substring-before(concat($siteUrl, '/'), concat('/', concat($ListUrl, '/')))" /> <!--<!– Remove Lists from the url –>--> <xsl:variable name="Lists"> <xsl:call-template name="StripSlash"> <xsl:with-param name="text" select="$urlLists"/> </xsl:call-template> </xsl:variable> <xsl:variable name="SPWebURLString" select="substring-before(concat($urlLists, '/'), concat('/', concat($Lists, '/')))" /> <xsl:value-of select="$SPWebURLString"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!--<!– this template Removes Lists from the url and used in SPWebUrl template –>--> <xsl:template name="StripSlash"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '/')"> <xsl:call-template name="StripSlash"> <xsl:with-param name="text" select="substring-after($text, '/')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!--this template for Strip HTML and used in dvt_1.rowview --> <xsl:template name="StripHTML"> <xsl:param name="HTMLText"/> <xsl:choose> <xsl:when test="contains($HTMLText, '<')"> <xsl:call-template name="StripHTML"> <xsl:with-param name="HTMLText" select="concat(substring-before($HTMLText, '<'), substring-after($HTMLText, '>'))"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$HTMLText"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!--this template for for displaying data in row view. it fatches data from results of search and displying in box format. --> <xsl:template name="dvt_1.rowview"> <xsl:variable name="dvt_StyleName">Table</xsl:variable> <xsl:variable name="Rows" select="/All_Results/Result"/> <div class="contentBox float_l"> <div class="Title"> <h1> <a> <xsl:attribute name="href"> <xsl:call-template name="SPWebUrl"> <xsl:with-param name="siteUrl" select="sitename" /> <xsl:with-param name="contentclass" select="contentclass" /> </xsl:call-template> </xsl:attribute> <xsl:value-of select="title" /> </a> </h1> </div> <div class="flotBox"> <p class="left"> <xsl:value-of select="author"/> </p> <p class="right"> <xsl:value-of select="write"/> </p> </div> <div class="norText"> <xsl:choose> <xsl:when test="string-length(description) < 175"> <div> <xsl:call-template name="StripHTML"> <xsl:with-param name="HTMLText" select="description"></xsl:with-param> </xsl:call-template> </div> </xsl:when> <xsl:otherwise> <div> <xsl:call-template name="StripHTML"> <xsl:with-param name="HTMLText" select="substring(description,1,135)"></xsl:with-param> </xsl:call-template> </div> </xsl:otherwise> </xsl:choose> <div> <xsl:choose> <xsl:when test="string-length(description) < 175"> </xsl:when> <xsl:otherwise> <a onclick="javascript:moreless(this,'{description}')"> <xsl:attribute name="href"> <xsl:call-template name="SPWebUrl"> <xsl:with-param name="siteUrl" select="sitename" /> <xsl:with-param name="contentclass" select="contentclass" /> </xsl:call-template> </xsl:attribute> More... </a> </xsl:otherwise> </xsl:choose> </div> </div> </div> </xsl:template> <xsl:include href="/_layouts/xsl/main.xsl"/> <xsl:include href="/_layouts/xsl/internal.xsl"/> <xsl:template name="FieldRef_Computed_DocIcon_body.DocIcon" ddwrt:dvt_mode="body" match ="FieldRef[@Name='DocIcon']" mode="Computed_DocIcon_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal"> <xsl:param name="thisNode" select="."/> <xsl:param name="folderUrlAdditionalQueryString" select="''"/> <xsl:choose> <xsl:when test="$thisNode/@FSObjType='1'"> <xsl:variable name="alttext"> <xsl:choose> <xsl:when test="starts-with($thisNode/@ContentTypeId, "0x0120D5")"> <xsl:value-of select="$thisNode/../@itemname_documentset"/>: <xsl:value-of select="$thisNode/@FileLeafRef"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$thisNode/../@listformtitle_folder"/>: <xsl:value-of select="$thisNode/@FileLeafRef"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="mapico" select="$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapico"/> <xsl:variable name="folderIconPath"> <xsl:call-template name="GetFolderIconSourcePath"> <xsl:with-param name="thisNode" select="$thisNode"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$RecursiveView='1'"> <img border="0" alt="{$alttext}" src="{$folderIconPath}" /> <xsl:choose> <xsl:when test="$thisNode/@IconOverlay != ''"> <img src="/_layouts/images/{$thisNode/@IconOverlay.mapoly}" class="ms-vb-icon-overlay" alt="" title="" /> </xsl:when> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:variable name="FolderCTID"> <xsl:value-of select="$PagePathFinal" />RootFolder=<xsl:value-of select="$thisNode/@FileRef.urlencode" /><xsl:value-of select="$ShowWebPart"/>&FolderCTID=<xsl:value-of select="$thisNode/@ContentTypeId" />&View=<xsl:value-of select="$View"/><xsl:value-of select="$folderUrlAdditionalQueryString"/> </xsl:variable> <a href="{$FolderCTID}" onmousedown ="VerifyFolderHref(this, event, '{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}', '{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}', '{$thisNode/@HTML_x0020_File_x0020_Type}', '{$thisNode/@serverurl.progid}')" onclick="return HandleFolder(this,event,"{$PagePathFinal}RootFolder=" + escapeProperly("{$thisNode/@FileRef}") + '{$ShowWebPart}&FolderCTID={$thisNode/@ContentTypeId}&View={$View}{$folderUrlAdditionalQueryString}','TRUE','FALSE','{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@HTML_x0020_File_x0020_Type}','{$thisNode/@serverurl.progid}','{$thisNode/@CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/@ForceCheckout}','{$thisNode/@IsCheckedoutToLocal}','{$thisNode/@PermMask}');"> <img border="0" alt="{$alttext}" title="{$alttext}" src="{$folderIconPath}" /> <xsl:choose> <xsl:when test="$thisNode/@IconOverlay != ''"> <img src="/_layouts/images/{$thisNode/@IconOverlay.mapoly}" class="ms-vb-icon-overlay" alt="" title="" /> </xsl:when> </xsl:choose> </a> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$IsDocLib"> <xsl:choose> <xsl:when test="not ($thisNode/@IconOverlay) or $thisNode/@IconOverlay =''"> <xsl:choose> <xsl:when test="not ($thisNode/@CheckoutUser.id) or $thisNode/@CheckoutUser.id =''"> <img border="0" alt="{$thisNode/@FileLeafRef}" title="{$thisNode/@FileLeafRef}" src="/_layouts/images/{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapico}"/> </xsl:when> <xsl:otherwise> <xsl:variable name="alttext"> <xsl:value-of select="$thisNode/@FileLeafRef"/><xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text><xsl:value-of select="$thisNode/../@managecheckedoutfiles_header_checkedoutby"/>: <xsl:value-of select="$thisNode/@CheckoutUser.title"/> </xsl:variable> <img border="0" alt="{$alttext}" title="{$alttext}" src="/_layouts/images/{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapico}" /> <img src="/_layouts/images/checkoutoverlay.gif" class="ms-vb-icon-overlay" alt="{$alttext}" title="{$alttext}" /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise > <img border="0" alt="{$thisNode/@FileLeafRef}" title="{$thisNode/@FileLeafRef}" src="/_layouts/images/{$thisNode/@IconOverlay.mapico}" /> <img src="/_layouts/images/{$thisNode/@IconOverlay.mapoly}" class="ms-vb-icon-overlay" alt="" title="" /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <img border="0" src="/_layouts/images/{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapico}"> <xsl:attribute name="title"> <xsl:value-of select="$thisNode/@Title"/> </xsl:attribute> <xsl:attribute name="alt"> <xsl:value-of select="$thisNode/@Title"/> </xsl:attribute> </img> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Search Result :
Comments
Post a Comment