Item - Compare portlet

From VYRE

(Redirected from Item compare portlet)
Jump to: navigation, search
Item - Compare portlet
module: Content module
supplier: VYRE Ltd.
Item Compare Portlet
Item Compare Portlet Configuration
Item Compare Example

Item compare portlet is used to compare two versions of an item. The portlet will highlight any changes between each version. This only applies to content and metadata changes. Taxonomy and links are not versioned and will therefore not be highlighted.

Contents

Configuration

You can add the item compare portlet from the portlet list. It is under the content portlets category. You need to pass in via the url the collection id of the item and the item id. without either of these the item compare portlet will not display

"?schemaId=12&itemId=12345"

Item compare Configuration

On the choose page change the configurations as shown in the image on the right. An example of a XSL template which can be used in the item compare portlet. This xsl template needs to be created in the "others" folder in the xsl folder (see publishing module) if you want the compare result contained on a different page then you need to have a view page for the compare result and put the location of the page into the second box labelled as "select page to display difference". If you are happy to have the result on the first page then leave this field blank. You need to have the "display HTML for selecting versions" boolean box ticked for this page so the options for selecting which item versions you want to compare with are displayed.

Item Compare example Xsl Template

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY nbsp "&#160;">
  4. <!ENTITY copy "&#169;">
  5. <!ENTITY reg "&#174;">
  6. <!ENTITY trade "&#8482;">
  7. <!ENTITY mdash "&#8212;">
  8. <!ENTITY ldquo "&#8220;">
  9. <!ENTITY rdquo "&#8221;">
  10. <!ENTITY pound "&#163;">
  11. <!ENTITY yen "&#165;">
  12. <!ENTITY euro "&#8364;">
  13. <!ENTITY amp "&#8364;">
  14. ]>
  15. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  16.     <xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes"/>
  17.  
  18.     <xsl:param name="parent_path">
  19.     </xsl:param>
  20.     <xsl:param name="current_path">
  21.     </xsl:param>
  22.     <xsl:param name="context_path">
  23.     </xsl:param>
  24.  
  25.     <xsl:template match="/">
  26.         <!--textarea><xsl:copy-of select="*"/></textarea-->
  27.         <xsl:for-each select="diffgram">
  28.             <xsl:variable name="allIsChanged" select="@changed"/>
  29.             <xsl:variable name="itemId" select="@itemId"/>
  30.             <xsl:variable name="schemaId" select="@schemaId"/>
  31.             <xsl:variable name="sourceVersion" select="@sourceVersion"/>
  32.             <xsl:variable name="modVersion" select="@modVersion"/>
  33.  
  34.             <!-- Display the two versions -->
  35.             <xsl:if test="@sourceVersion != ''">
  36.  
  37.                 <xsl:choose>
  38.                     <xsl:when test="$allIsChanged = 'no'">
  39.                         <h2>
  40.                             The two versions are identical
  41.                         </h2>
  42.                     </xsl:when>
  43.                     <xsl:otherwise>
  44.                         <h2>
  45.                             Version Comparison
  46.                         </h2>
  47.                     </xsl:otherwise>
  48.                 </xsl:choose>
  49.  
  50.                 <div id="legend" class="legend">
  51.                     <h3>
  52.                         Legend
  53.                     </h3>
  54.                     <span class="no-change">
  55.                         no change
  56.                     </span>
  57.                     <span class="style-del">
  58.                         removed
  59.                     </span>
  60.                     <span class="style-add">
  61.                         added
  62.                     </span>
  63.                     <span class="style-change-del">
  64.                         changed from
  65.                     </span>
  66.                     <span class="style-change-add">
  67.                         changed to
  68.                     </span>
  69.                 </div>
  70.                 <h2>
  71.                     Comparing versions<xsl:value-of select="@sourceVersion"/>and<xsl:value-of select="@modVersion"/>
  72.                 </h2>
  73.  
  74.                 <xsl:if test="@schemaId = '5'">
  75.                     <!-- If this is an asset -->
  76.                     <table>
  77.                         <tr>
  78.                             <th valign="top">
  79.                                 Version<xsl:value-of select="@sourceVersion"/>
  80.                             </th>
  81.                             <th>
  82.                                 &nbsp;
  83.                             </th>
  84.                             <th valign="top">
  85.                                 Version<xsl:value-of select="@modVersion"/>
  86.                             </th>
  87.                         </tr>
  88.                         <tr>
  89.                             <td valign="top">
  90.                                 <img src="/servlet/file/preview.jpg?ITEM_ENT_ID={@itemId}&amp;ITEM_VERSION={@sourceVersion}&amp;COLLSPEC_ENT_ID={@schemaId}&amp;FILE_SERVICE_CONF_ID=126" alt="Version {@sourceVersion}"/>
  91.                             </td>
  92.                             <td>
  93.                                 &nbsp;
  94.                             </td>
  95.                             <td valign="top">
  96.                                 <img src="/servlet/file/preview.jpg?ITEM_ENT_ID={@itemId}&amp;ITEM_VERSION={@modVersion}&amp;COLLSPEC_ENT_ID={@schemaId}&amp;FILE_SERVICE_CONF_ID=126" alt="Version {@modVersion}"/>
  97.                             </td>
  98.                         </tr>
  99.                     </table>
  100.                 </xsl:if>
  101.                 <!-- Display each section -->
  102.  
  103.                 <dl class="version-compare-list">
  104.  
  105.  
  106.                     <xsl:for-each select="section">
  107.  
  108.                         <xsl:for-each select="attribute">
  109.                             <xsl:call-template name="processAttribute">
  110.                                 <xsl:with-param name="attribute" select="."/>
  111.                                 <xsl:with-param name="allIsChanged" select="$allIsChanged"/>
  112.                             </xsl:call-template>
  113.                         </xsl:for-each>
  114.                     </xsl:for-each>
  115.  
  116.                 </dl>
  117.                 <br class="clear nbsp"/>
  118.                 <p>
  119.                     <a href="{$parent_path}/versions/?schemaId={$schemaId}&amp;itemId={$itemId}">
  120.                         Choose different versions to compare
  121.                     </a>
  122.                 </p>
  123.                 <p>
  124.                     <a href="{$parent_path}/view/item{$itemId}/">
  125.                         View active version
  126.                     </a>
  127.                 </p>
  128.             </xsl:if>
  129.         </xsl:for-each>
  130.     </xsl:template>
  131.  
  132.     <xsl:template name="processAttribute">
  133.         <xsl:param name="attribute"/>
  134.         <xsl:param name="allIsChanged"/>
  135.         <dt>
  136.             <xsl:value-of select="@name"/>
  137.         </dt>
  138.         <dd>
  139.             <xsl:if test="@changed = 'no' and $allIsChanged = 'yes'">
  140.                 (No change)&nbsp;
  141.             </xsl:if>
  142.             <xsl:for-each select="add | del | copy | change">
  143.                 <xsl:variable name="op" select="name()"/>
  144.                 <xsl:choose>
  145.                     <xsl:when test="name() = 'change'">
  146.                         <span class="style-change-del">
  147.                             <xsl:value-of select="from" disable-output-escaping="yes"/>
  148.                         </span>&nbsp;
  149.                         <span class="style-change-add">
  150.                             <xsl:value-of select="to" disable-output-escaping="yes"/>
  151.                         </span>
  152.                     </xsl:when>
  153.                     <xsl:when test="name() = 'add'">
  154.                         <span class="style-{$op}">
  155.                             <xsl:value-of select="." disable-output-escaping="yes"/>
  156.                         </span>&nbsp;
  157.                     </xsl:when>
  158.                     <xsl:when test="name() = 'del'">
  159.                         <span class="style-{$op}">
  160.                             <xsl:value-of select="." disable-output-escaping="yes"/>
  161.                         </span>&nbsp;
  162.                     </xsl:when>
  163.                     <xsl:otherwise>
  164.                         <span class="style-{$op}">
  165.                             <xsl:value-of select="." disable-output-escaping="yes"/>
  166.                         </span>&nbsp;
  167.                     </xsl:otherwise>
  168.                 </xsl:choose>
  169.             </xsl:for-each>
  170.             &nbsp;
  171.         </dd>
  172.  
  173.     </xsl:template>
  174.  
  175.  
  176. </xsl:stylesheet>

See Also

Personal tools