Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sherry Ann Hernandez 320 posts 344 karma points
    Apr 09, 2011 @ 10:20
    Sherry Ann Hernandez
    0

    Sort xslt from 6 different nodes

    Hi,

    I'm displaying my content from 6 different nodes. Here's the sample code. My problem is sorting it.

    Is it possible to pull the data from the 6 different nodes and then store it in somehow temp variable so I can I sort it there accordingly?

      <xsl:for-each select="umbraco.library:GetXmlNodeById($myNode)/* [@isDoc and showLink = 1]">
       <tr id="meetingRow{@id}" lang="{@id}">
        <xsl:choose>
         <xsl:when test="(position() mod 2) = 0">
          <xsl:attribute name="class">alternative</xsl:attribute>
         </xsl:when>
         <xsl:otherwise>
          <xsl:attribute name="class">meetingRow</xsl:attribute>
         </xsl:otherwise>
        </xsl:choose>
        <td align="left" class="itemList">
         <div class="banquetName"><xsl:value-of select="@nodeName"/></div>
          <xsl:variable name="mediaNode1" select="umbraco.library:GetMedia(1951, false())" />
                          <xsl:variable name="toolTip" select="'HotelRating2.aspx'"/>
                                <div class="thumbsUp" id="meetingThumbsUp{@id}" style="width:21px;">
           <a class="thumbs_up_icon" href="javascript:;" rel="{$toolTip}?id={@id}&amp;hotelID=1,{@id}" onmouseout="hideReviewRating()"/>
          </div>
         <br/>
         <div class="banquetLinks">
          <a id="{@id}" class="locationB" href="javascript:;" style="width:70px;"><xsl:value-of select="umbraco.library:GetDictionaryItem('location and contact')"/></a>
          <div style="display:none;">
           <div id="location{@id}" style="height:220px;width:530px;background-color:#f5e9ca;float:left;text-align:left;">
            <div style="height:20px;width:530px;background-color:#201913;color:#fff;font-size:11px;"><xsl:value-of select="umbraco.library:GetDictionaryItem('location and contact')"/></div>
            <h2 style="color:#3b2314;margin-left:10px;font-size:16px;"><xsl:value-of select="@nodeName"/>, <xsl:value-of select="$floraGrand/hotelName"/></h2>
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($floraGrand/mapThumbnail, false())" />
            <div style="float:left;margin:10px 0 10px 10px;width:65px">
             <xsl:if test="imageThumbnail != ''">
              <xsl:variable name="mediaNode2" select="umbraco.library:GetMedia(imageThumbnail, false())" />
              <img alt="Flora Grand" src="{$mediaNode2/umbracoFile}" Width="60" style="margin-bottom:10px;" class="meetingThumbnail"/>    
             </xsl:if>
             <img alt="Flora Grand" src="http://image1.floraagents.com{$mediaNode/umbracoFile}" height="60" Width="60"  class="meetingThumbnail"/>
            </div>
            <div style="float:left;margin:9px 0 10px 10px;width:440px">
             <div class="hotelDescription"><xsl:value-of select="$floraGrand/streetAddress"/></div>
             <div class="hotelDescription"><xsl:value-of select="$floraGrand/city"/>,&nbsp;<xsl:value-of select="$floraGrand/region"/></div>
             <div class="hotelDescription"><xsl:value-of select="$floraGrand/country"/></div>
             <div class="hotelDescription">P.O. Box: <xsl:value-of select="$floraGrand/zipCode"/></div>
             <div class="hotelDescription"><xsl:value-of select="umbraco.library:GetDictionaryItem('contact banquet sales')"/>: <xsl:value-of select="$floraGrand/banquetTelephone"/></div>
             <div class="hotelDescription"><xsl:value-of select="umbraco.library:GetDictionaryItem('fast track reservation')"/>: <xsl:value-of select="$floraGrand/telephone"/></div>
            </div>
           </div>
          </div>
          <xsl:if test="listOfAmenities != ''">
           |&nbsp;<a id="{@id}" class="amenities" href="javascript:;" style="width:60px;"><xsl:value-of select="umbraco.library:GetDictionaryItem('amenities')"/></a>
           <div style="display:none"><div id="amenities{@id}" class="amenitiesDiv" style="height:450px;width:400px;background-color:#f5e9ca;float:left;text-align:left">
            <div style="height:20px;width:400px;background-color:#201913;color:#fff;font-size:11px;"><xsl:value-of select="umbraco.library:GetDictionaryItem('amenities')"/></div>
            <h2 style="color:#3b2314;margin-left:10px;font-size:16px;"><xsl:value-of select="@nodeName"/>, <xsl:value-of select="$floraGrand/hotelName"/></h2>
            <ul style="color:#3b2314;font-size:12px;"> 
             <xsl:for-each select="listOfAmenities/data/item">   
              <li><xsl:value-of select="." /></li>
             </xsl:for-each>    
            </ul>  
           </div></div>
          </xsl:if>
         </div>
         <div>
          <xsl:if test="imageGallery != ''">
           <a hef="javascript:;" class="imageGallery" style="width:60px;">
           <xsl:variable name="imageP" select="umbraco.library:GetMedia(imageGallery, 1)" />
           <xsl:variable name="tCount" select="count($imageP/*)"/>
           <xsl:if test="count($imageP/*) &gt; 0"> 
             <xsl:attribute name="rel">
              <xsl:for-each select="$imageP/*">
               <xsl:if test="./umbracoFile != ''"><xsl:value-of select="./umbracoFile"/>
               <xsl:if test="position() != last() and position() != 1">,</xsl:if></xsl:if>
              </xsl:for-each>
             </xsl:attribute>
             <xsl:attribute name="title">
              <xsl:for-each select="$imageP/*">
               <xsl:if test="./umbracoFile != ''"><xsl:value-of select="@nodeName"/>|<xsl:value-of select="$floraGrand/hotelName"/>|<xsl:value-of select="$floraGrand/banquetTelephone"/>
               <xsl:if test="position() != last() and position() != 1">,</xsl:if></xsl:if>
              </xsl:for-each>
             </xsl:attribute>
           </xsl:if><xsl:value-of select="umbraco.library:GetDictionaryItem('Images')"/></a>
          </xsl:if>
          <xsl:if test="imageGallery != '' and floorPlan != ''">|</xsl:if>
          <xsl:if test="floorPlan != ''">
           <a hef="javascript:;" class="floorPlan" style="width:60px;">
           <xsl:variable name="floorP" select="umbraco.library:GetMedia(floorPlan, 0)" />
           <xsl:attribute name="title">
            <xsl:value-of select="@nodeName"/>|<xsl:value-of select="$floraGrand/hotelName"/>|<xsl:value-of select="$floraGrand/banquetTelephone"/>
           </xsl:attribute>
           <xsl:attribute name="rel">
            <xsl:value-of select="$floorP/umbracoFile"/>
           </xsl:attribute><xsl:value-of select="umbraco.library:GetDictionaryItem('floor plan')"/></a>
          </xsl:if>
          <xsl:if test="(imageGallery != '' or floorPlan != '') and virtualTourFile != ''">| </xsl:if> 
          <xsl:if test="virtualTourFile != ''">
           <a hef="javascript:;" class="virtualTour" style="width:60px;">
           <xsl:variable name="virtual" select="umbraco.library:GetMedia(virtualTourFile, 0)" />
           <xsl:attribute name="title">
            <xsl:value-of select="@nodeName"/>|<xsl:value-of select="$floraGrand/hotelName"/>|<xsl:value-of select="$floraGrand/banquetTelephone"/>
           </xsl:attribute>
           <xsl:attribute name="rel">
            <xsl:value-of select="$virtual/umbracoFile"/>
           </xsl:attribute><xsl:value-of select="umbraco.library:GetDictionaryItem('virtual tour')"/></a>
          </xsl:if>
         </div>
        </td>
        <td align="center" class="itemList">
     
         <xsl:if test="banquetType != ''">
             <xsl:variable name="banquetT" select="umbraco.library:Split(banquetType, ',')" />
          <xsl:for-each select="$banquetT/value">   
           <xsl:value-of select="." /><xsl:if test="position() != last()">, <br/></xsl:if>
          </xsl:for-each>
         </xsl:if>
        </td>
        <td align="center" class="itemList"><xsl:value-of select="dimensionM"/></td>
        <td align="center" class="itemList">
         <xsl:if test="areSQM != ''">
          <xsl:value-of select="areSQM"/> / <xsl:variable name="divisor" select="0.09290304"/> <xsl:value-of select="floor(areSQM div $divisor)"/>
         </xsl:if>
        </td>
        <td align="center" class="itemList"><xsl:value-of select="theatre"/></td>
        <td align="center" class="itemList"><xsl:value-of select="classroom"/></td>
        <td align="center" class="itemList"><xsl:value-of select="u-Shape"/></td>
        <td align="center" class="itemList"><xsl:value-of select="hollowSQ"/></td>
        <td align="center" class="itemList"><xsl:value-of select="boardroom"/></td>
        <td align="center" class="itemList"><xsl:value-of select="cabaret"/></td>
        <td align="center" class="itemList"><xsl:value-of select="banquet"/></td>
       </tr>
      </xsl:for-each>
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Apr 09, 2011 @ 11:03
    Chriztian Steinmeier
    0

    Hi Sherry Ann,

    You can do exactly that - in short, something like this will do:

    <!-- Grab nodes from all over the place -->
    <xsl:variable name="set1" select="..." />
    <xsl:variable name="set2" select="..." />
    <xsl:variable name="set3" select="..." />
    
    <!-- Combine in one set and sort descending by created date -->
    <xsl:for-each select="$set1 | $set2 | $set3">
        <xsl:sort select="@createDate" data-type="text" order="descending" />
    
        <!-- do stuff -->
    
    </xsl:for-each>

    /Chriztian

  • Sherry Ann Hernandez 320 posts 344 karma points
    Apr 09, 2011 @ 14:04
    Sherry Ann Hernandez
    0

    Hi Chriztian,

    Since I have multiple sort order I'm trying to pass a variable on the sort statement.

     I try this

       <xsl:if test="$source = 'theatre'">
                                 <xsl:sort select="theatre" data-type="text" order="ascending" />
       </xsl:if>

    and this

      <xsl:sort select="{$sortBy}" data-type="text" order="{$sortType}" />

    But both is not working. I just get a xslt error.

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Apr 09, 2011 @ 18:26
    Chriztian Steinmeier
    1

    Hi Sherry Ann,

    Yeah - unfortunately you're not allowed to use variables in the sort attributes - but here's a neat little trick that'll work:

    <xsl:template match="/">
        <xsl:variable name="sortBy" select="umbraco.library:RequestQueryString('sort')" />
        <xsl:variable name="sortDir" select="umbraco.library:RequestQueryString('dir')" />
    
        <xsl:for-each select="*">
            <!-- Sorting using the "Mutually Exclusive" hack... -->
            <xsl:sort select="theatre[$sortBy = 'theatre' and $sortDir = 'asc']" data-type="text" order="ascending" />
            <xsl:sort select="theatre[$sortBy = 'theatre' and $sortDir = 'desc']" data-type="text" order="descending" />
    
            <xsl:sort select="datePlaying[$sortBy = 'date' and $sortDir = 'asc']" data-type="text" order="ascending" />
            <xsl:sort select="datePlaying[$sortBy = 'date' and $sortDir = 'desc']" data-type="text" order="descending" />
    
            <!-- do stuff -->
    
        </xsl:for-each>
    </xsl:template>

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft