Wednesday, May 18, 2016

People Search Core Results XSL Display

1 - In Results Query Options define the Fixed Keyword Query like in a Search Box.

2 - In Display Properties under XSL Editor define your XML Stylesheet (or a link to an external file, as below):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    <xsl:include href="/EN/dt/dtsystemfiles/xslsheets/tu-who-is-who-en.xsl"/>
</xsl:stylesheet>

3 - The external file, to adapt conveniently:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:param name="ResultsBy" />
  <xsl:param name="ViewByUrl" />
  <xsl:param name="ViewByValue" />
  <xsl:param name="IsNoKeyword" />
  <xsl:param name="IsFixedQuery" />
  <xsl:param name="MoreResultsText" />
  <xsl:param name="MoreResultsLink" />
  <xsl:param name="CollapsingStatusLink" />
  <xsl:param name="CollapseDuplicatesText" />
  <xsl:param name="MeHeaderValue" />
  <xsl:param name="CollHeaderValue" />
  <xsl:param name="CollOfCollHeaderValue" />
  <xsl:param name="EveryoneHeaderValue" />
  <xsl:param name="AddToMyColleaguesText" />
  <xsl:param name="SrchRSSText" />
  <xsl:param name="SrchRSSLink" />
  <xsl:param name="ShowMessage" />
  <xsl:param name="ShowActionLinks" />

  <!-- When there is keywory to issue the search -->
  <xsl:template name="dvt_1.noKeyword">
    <span class="ms-sbplain">
      <xsl:choose>
        <xsl:when test="$IsFixedQuery">
          Please set the 'Fixed Query' property for the webpart.
        </xsl:when>
        <xsl:otherwise>
          Enter one or more words to search for in the search box.
        </xsl:otherwise>
      </xsl:choose>
    </span>
  </xsl:template>

  <!-- When empty result set is returned from search -->
  <xsl:template name="dvt_1.empty">
    <xsl:if test="$ShowActionLinks">
      <div class="srch-sort">
        <xsl:if test="string-length($SrchRSSLink) &gt; 0">
          <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
            <img border="0" src="/_layouts/images/rss.gif" alt=""/>
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$SrchRSSText"/>
          </a>
        </xsl:if>
      </div>
    </xsl:if>
    <br/>
    <br/>

    <span class="ms-sbplain" id="CSR_NO_RESULTS">
      No results matching your search were found.

      <ol>
        <li>Check your spelling. Are the words in your query spelled correctly?</li>
        <li>Try using synonyms. Maybe what you're looking for uses slightly different words.</li>
        <li>Make your search more general. Try more general terms in place of specific ones.</li>
        <li>Try your search in a different scope. Different scopes can have different results.</li>
      </ol>
    </span>
  </xsl:template>


  <!-- Main body template. Sets the Results view (Relevance or date) options -->
  <xsl:template name="dvt_1.body">
    <xsl:if test="$ShowActionLinks">
      <div class="srch-sort">
        <xsl:value-of select="$ResultsBy" />
        <xsl:if test="$ViewByUrl">
          |
          <a href ="{$ViewByUrl}" id="CSR_RV" title="{$ViewByValue}">
            <xsl:value-of select="$ViewByValue" />
          </a>
        </xsl:if>
        <xsl:if test="string-length($SrchRSSLink) &gt; 0">
          |
          <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
            <img border="0" src="/_layouts/images/rss.gif" alt=""/>
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$SrchRSSText"/>
          </a>
        </xsl:if>
      </div>
      <div style="margin-top: 15px;"></div>
      <br />
      <br />
    </xsl:if>
   
    <p>If this page is outdated please send the correct information to <a href="mailto:dt.webmaster">dt.webmaster</a></p>

    <table cellpadding="1" cellspacing="5" width="100%">
     
      <!--<xsl:for-each select="All_Results/Result">-->
     
<xsl:for-each select="All_Results/Result[jobtitle=starts-with(jobtitle,'Chef')]">
    <xsl:sort select="preferredname"/>
   
    <tr>
        <td>
            <xsl:choose>
              <xsl:when test="string-length(pictureurl)&gt;0">
                <xsl:variable name="picture" select="pictureurl"/>
                <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" />
              </xsl:when>
              <xsl:otherwise>
                 <img height="100" src="http://spjsnet/EN/dt/PublishingImages/blank-profile.jpg" alt="Photo non autoris&#233;e" border="0" />
              </xsl:otherwise>
          </xsl:choose>
        </td>
      
        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:text>Chief</xsl:text></strong><br />
        </td>

        <td>  
            <xsl:text>User:&#160;</xsl:text><strong><xsl:value-of select="substring-after(accountname,'\')"/></strong><br />
            <xsl:text>Phone:&#160;</xsl:text><strong><xsl:value-of select="workphone" /></strong><br />
            <xsl:text>Office:&#160;</xsl:text><strong><xsl:value-of select="officenumber" /></strong>
          </td>
          <td width="25%"></td>
    </tr>
      </xsl:for-each>
 

  <xsl:for-each select="All_Results/Result[jobtitle='Agent 1']">
    <xsl:sort select="preferredname"/>
   
    <tr>
   
        <td>
            <xsl:choose>
              <xsl:when test="string-length(pictureurl)&gt;0">
                <xsl:variable name="picture" select="pictureurl"/>
                <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" />
              </xsl:when>
              <xsl:otherwise>
                 <img height="100" src="http://spjsnet/EN/dt/PublishingImages/blank-profile.jpg" alt="Photo non autoris&#233;e" border="0" />
              </xsl:otherwise>
          </xsl:choose>
        </td>

        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:text>Agent1</xsl:text></strong><br />
        </td>
        <td>  
            <xsl:text>User:&#160;</xsl:text><strong><xsl:value-of select="substring-after(accountname,'\')"/></strong><br />
            <xsl:text>Phone:&#160;</xsl:text><strong><xsl:value-of select="workphone" /></strong><br />
            <xsl:text>Office:&#160;</xsl:text><strong><xsl:value-of select="officenumber" /></strong>
          </td>
          <td width="25%">
              <xsl:text>Language&#160;coverage:&#160;</xsl:text><br />
            <!--<xsl:value-of select="languages"/>-->
            <strong><xsl:value-of select="translate(Agent1languages, ';',' ')"/></strong>
          </td>
    </tr>
      </xsl:for-each>


  <xsl:for-each select="All_Results/Result[jobtitle='Administrateur']">
    <xsl:sort select="preferredname"/>
   
    <tr>
   
        <td>
            <xsl:choose>
              <xsl:when test="string-length(pictureurl)&gt;0">
                <xsl:variable name="picture" select="pictureurl"/>
                <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" />
              </xsl:when>
              <xsl:otherwise>
                 <img height="100" src="http://spjsnet/EN/dt/PublishingImages/blank-profile.jpg" alt="Photo non autoris&#233;e" border="0" />
              </xsl:otherwise>
          </xsl:choose>
        </td>

        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:text>Agent1</xsl:text></strong><br />
        </td>
        <td>  
            <xsl:text>User:&#160;</xsl:text><strong><xsl:value-of select="substring-after(accountname,'\')"/></strong><br />
            <xsl:text>Phone:&#160;</xsl:text><strong><xsl:value-of select="workphone" /></strong><br />
            <xsl:text>Office:&#160;</xsl:text><strong><xsl:value-of select="officenumber" /></strong>
          </td>
          <td width="25%">
              <xsl:text>Language&#160;coverage:&#160;</xsl:text><br />
            <!--<xsl:value-of select="languages"/>-->
            <strong><xsl:value-of select="translate(Agent1anguages, ';',' ')"/></strong>
          </td>
    </tr>
      </xsl:for-each>

     
   <xsl:for-each select="All_Results/Result[jobtitle='Agent 2']">
    <xsl:sort select="preferredname"/>
   
    <tr>

        <td>
            <xsl:choose>
              <xsl:when test="string-length(pictureurl)&gt;0">
                <xsl:variable name="picture" select="pictureurl"/>
                <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" />
              </xsl:when>
              <xsl:otherwise>
                 <img height="100" src="http://spjsnet/EN/dt/PublishingImages/blank-profile.jpg" alt="Photo non autoris&#233;e" border="0" />
              </xsl:otherwise>
          </xsl:choose>
        </td>

        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:value-of select="jobtitle" /></strong><br />
        </td>
        <td>  
            <xsl:text>Utilisateur:&#160;</xsl:text><strong><xsl:value-of select="substring-after(accountname,'\')"/></strong><br />
            <xsl:text>T&#233;l.:&#160;</xsl:text><strong><xsl:value-of select="workphone" /></strong><br />
            <xsl:text>Bureau:&#160;</xsl:text><strong><xsl:value-of select="officenumber" /></strong>
          </td>
          <td width="25%"></td>
    </tr>
      </xsl:for-each>
     
   <xsl:for-each select="All_Results/Result[jobtitle='Secr&#233;taire']">
    <xsl:sort select="preferredname"/>
   
    <tr>

        <td>
            <xsl:choose>
              <xsl:when test="string-length(pictureurl)&gt;0">
                <xsl:variable name="picture" select="pictureurl"/>
                <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" />
              </xsl:when>
              <xsl:otherwise>
                 <img height="100" src="http://spjsnet/EN/dt/PublishingImages/blank-profile.jpg" alt="Photo non autoris&#233;e" border="0" />
              </xsl:otherwise>
          </xsl:choose>
        </td>

        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:text>Secretary</xsl:text></strong><br />
        </td>
        <td>  
            <xsl:text>Utilisateur:&#160;</xsl:text><strong><xsl:value-of select="substring-after(accountname,'\')"/></strong><br />
            <xsl:text>T&#233;l.:&#160;</xsl:text><strong><xsl:value-of select="workphone" /></strong><br />
            <xsl:text>Bureau:&#160;</xsl:text><strong><xsl:value-of select="officenumber" /></strong>
          </td>
          <td width="25%"></td>
    </tr>
      </xsl:for-each>


     
  <!--<xsl:for-each select="All_Results/Result">
    <xsl:sort select="preferredname"/>
    <tr>
        <td>
            <strong><xsl:variable name="email" select="workemail"/>
                <a href="mailto:{$email}"><xsl:value-of select="preferredname"/></a></strong><br />
            <strong><xsl:value-of select="jobtitle" /></strong><br />
            <xsl:variable name="picture" select="pictureurl"/>
            <img height="100" src="{pictureurl}" alt="{preferredname}" border="0" /><br />
            <xsl:value-of select="substring-after(accountname,'\')"/><br />
            <strong><xsl:value-of select="workphone" /></strong><br />
            <strong><xsl:value-of select="officenumber" /></strong><br />
          </td>
    </tr>
  </xsl:for-each>-->
   
    </table>
      
    <xsl:call-template name="DisplayMoreResultsAnchor" />
  </xsl:template>


  <!-- This template is called for each result -->
<!--  <xsl:template match="All_Results/Result"> -->
    <xsl:template name="customsort">
    <xsl:variable name="id" select="id"/>
    <xsl:variable name="url" select="url"/>
    <xsl:variable name="email" select="workemail"/>
    <xsl:variable name="sip" select="sipaddress"/>
    <xsl:variable name="prefix">IMNRC('</xsl:variable>
    <xsl:variable name="suffix">')</xsl:variable>
    <!--<table class="psrch-result" CELLPADDING="0" CELLSPACING="0" BORDER="5" width="100%"> -->
    <tr>
      <!--
        <td valign="top" class="psrch-propcell" width="100%">
          <span class="psrch-Title">
            <xsl:value-of select="preferredname"/>
          </span>
        </td>
-->
    </tr>
    <!--    </table> -->
  </xsl:template>

  <xsl:template name="HitHighlighting">
    <xsl:param name="hh" />
    <xsl:apply-templates select="$hh"/>
  </xsl:template>

  <xsl:template match="ddd">
    &#8230;
  </xsl:template>
  <xsl:template match="c0">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c1">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c2">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c3">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c4">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c5">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c6">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c7">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c8">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>
  <xsl:template match="c9">
    <b>
      <xsl:value-of select="."/>
    </b>
  </xsl:template>

  <xsl:template match="All_Results/DummyResult/Me">
    <span class="srch-SocDistTitle">
      <xsl:value-of select="$MeHeaderValue" />
    </span>

  </xsl:template>

  <xsl:template match="All_Results/DummyResult/Colleague">
    <span class="srch-SocDistTitle">
      <xsl:value-of select="$CollHeaderValue" />
    </span>

  </xsl:template>
  <xsl:template match="All_Results/DummyResult/ColleagueOfColleague">
    <span class="srch-SocDistTitle">
      <xsl:value-of select="$CollOfCollHeaderValue" />
    </span>
  </xsl:template>

  <xsl:template match="All_Results/DummyResult/Everyone">
    <span class="srch-SocDistTitle">
      <!-- (everyoneheadervalue) <xsl:value-of select="$EveryoneHeaderValue" /> -->
      Transportation Department Team Members and Contacts
    </span>
  </xsl:template>

  <!-- The "view more results" for fixed query -->
  <xsl:template name="DisplayMoreResultsAnchor">
    <xsl:if test="$MoreResultsLink">
      <a href="{$MoreResultsLink}">
        <xsl:value-of select="$MoreResultsText"/>
      </a>
    </xsl:if>
  </xsl:template>

  <xsl:template name="DisplayAddToMyColleaguesLink">
    <xsl:param name="url"/>
    <a href="{$url}">
      <xsl:value-of select="$AddToMyColleaguesText"/>
    </a>
    <br/>
  </xsl:template>

  <!-- document collapsing link setup -->
  <xsl:template name="DisplayCollapsingStatusLink">
    <xsl:param name="status"/>
    <xsl:param name="url"/>
    <xsl:if test="$CollapsingStatusLink">
      <xsl:choose>
        <xsl:when test="$status=1">
          <br/>
          <xsl:variable name="CollapsingStatusHref" select="concat(substring-before($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'), 'duplicates:&quot;', $url, '&quot;', substring-after($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'))"/>
          [<a href="{$CollapsingStatusHref}" title="{$CollapseDuplicatesText}">
            <xsl:value-of select="$CollapseDuplicatesText"/>
          </a>]
        </xsl:when>
      </xsl:choose>
    </xsl:if>
  </xsl:template>

  <!-- XSL transformation starts here -->
  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$IsNoKeyword = 'True'" >
        <xsl:call-template name="dvt_1.noKeyword" />
      </xsl:when>
      <xsl:when test="$ShowMessage = 'True'">
        <xsl:call-template name="dvt_1.empty" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="dvt_1.body"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="DisplayOfficeProfile">
    <xsl:param name="title" />
    <xsl:param name="dep" />
    <xsl:param name="phone" />
    <xsl:param name="office" />
   
    <span class="psrch-Metadata">
      <xsl:if test='string-length($title) &gt; 0'>
        (title?) <xsl:value-of select="$title" />
        -
      </xsl:if>
      <xsl:if test='string-length($dep) &gt; 0'>
        (department?) <xsl:value-of select="$dep" />
        -
      </xsl:if>
      <xsl:if test='string-length($phone) &gt; 0'>
        (phone?) <xsl:value-of select="$phone" />
        -
      </xsl:if>
      <xsl:if test='string-length($office) &gt; 0'>
        (office?)
        <xsl:value-of select="$office" />
      </xsl:if>
    </span>
    <br/>
  </xsl:template>

  <!-- End of Stylesheet -->
</xsl:stylesheet>

No comments:

Post a Comment