Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListText Listing - Sort by valuesText Listing - Sort by values
Previous
 
Next
New Post
2/13/2012 12:55 PM
 

Hello..
I have a "group" text box which is being displayed as a vertical radio button list.  The items which are available are:

Bridge/Culvert Projects|3;County Road Projects|4;General Documents|1;Instructions|2;Township Road Projects|5

As you can see, the list is shown alphabetically, but their corresponding numbers are different.  I want the groups sorted by their numbers instead of their actual text values.

Is this possible to accomplish from within the XSL style sheet?

Thanks.. -Jeff


 
New Post
2/13/2012 7:19 PM
 

I was able to figure something out which works quite well.

In case someone else is looking for something similar, this is what I did.

Text box named Group and its options (InputSettings) were Bridge/Culvert Projects|5;County Road Projects|3;General Documents|1;Instructions|2;Township Road Projects|4.  I set them up to be a vertical Radio Button List.  This works well.

If I select County Road Projects, a 3 is entered into the UDT database; but I needed it to display County Road Projects instead on the webpage.  BUT, I also needed it to sort by the numbers so that General Documents is first, Instructions are second, etc.  How to do this automatically without having to have the end-users select a number manually, was a concern as well.

Within the XSL, I created it to be an Unordered list.  I also have grouping turned on so that it'll group like items by their group.  See below.  This works just as I had hoped.  Beginning with the Choose-When option at line 47, this determines what is displayed as the header followed by the items underneath their respected groups.

_____________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:udt="DotNetNuke/UserDefinedTable" exclude-result-prefixes="udt">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
  <!--
  This prefix is used to generate module specific query strings
  Each querystring or form value that starts with udt_{ModuleId}_param 
  will be added as parameter starting with param
  -->
  <xsl:variable name="prefix_param">udt_<xsl:value-of select="//udt:Context/udt:ModuleId" />_param</xsl:variable>
  <xsl:key name="data-by-group" match="udt:Data" use="udt:Group" />


  <xsl:template match="udt:Data" mode="list">
    <li>
      <table width="100%">
<xsl:choose>
 <xsl:when test="udt:Group='1' or udt:Group='2'">
   <tr>
     <td valign="top">
       <div style="padding: 2px;">
         <xsl:call-template name="EditLink" />
         <xsl:value-of select="udt:Information" disable-output-escaping="yes" />
       </div>
     </td>
   </tr>
 </xsl:when>
 <xsl:otherwise>
   <tr>
     <td valign="top">
       <div style="padding: 2px;">
         <xsl:call-template name="EditLink" />
         <xsl:value-of select="udt:Information" disable-output-escaping="yes" />
 :&#160;Bid Date - 
         <xsl:value-of select="udt:Bid_x0020_Date_UDT_Value" disable-output-escaping="yes" />
       </div>
     </td>
  </tr>
</xsl:otherwise>
</xsl:choose>
      </table>
    </li>
  </xsl:template>


  <xsl:template match="/udt:UserDefinedTable">
    <ul>
      <xsl:for-each select="udt:Data[count(. | key('data-by-group', udt:Group)[1]) = 1]">
 <xsl:sort select="udt:Group" order="ascending" />
        <xsl:choose>
          <xsl:when test="udt:Group='1'">
            <li style="padding: 0 0 15px 0;">
              <div style="font-size: 14px;">
                GENERAL DOCUMENTS:
              </div>
              <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
              <xsl:if test="$currentData">
                <ul>
                  <xsl:apply-templates select="$currentData" mode="list">
                    <xsl:sort select="udt:Bid_x0020_Date_UDT_Value" order="ascending" />
                  </xsl:apply-templates>
                </ul>
              </xsl:if>
            </li>
          </xsl:when>


          <xsl:when test="udt:Group='2'">
            <li style="padding: 0 0 15px 0;">
              <div style="font-size: 14px;">
                INSTRUCTIONS:
              </div>
              <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
              <xsl:if test="$currentData">
                <ul>
                  <xsl:apply-templates select="$currentData" mode="list">
                    <xsl:sort select="udt:Bid_x0020_Date_UDT_Value" order="ascending" />
                  </xsl:apply-templates>
                </ul>
              </xsl:if>
            </li>
          </xsl:when>


          <xsl:when test="udt:Group='3'">
            <li style="padding: 0 0 15px 0;">
              <div style="font-size: 14px;">
                COUNTY ROAD PROJECTS:
              </div>
              <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
              <xsl:if test="$currentData">
                <ul>
                  <xsl:apply-templates select="$currentData" mode="list">
                    <xsl:sort select="udt:Bid_x0020_Date_UDT_Value" order="ascending" />
                  </xsl:apply-templates>
                </ul>
              </xsl:if>
            </li>
          </xsl:when>


          <xsl:when test="udt:Group='4'">
            <li style="padding: 0 0 15px 0;">
              <div style="font-size: 14px;">
                TOWNSHIP ROAD PROJECTS:
              </div>
              <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
              <xsl:if test="$currentData">
                <ul>
                  <xsl:apply-templates select="$currentData" mode="list">
                    <xsl:sort select="udt:Bid_x0020_Date_UDT_Value" order="ascending" />
                  </xsl:apply-templates>
                </ul>
              </xsl:if>
            </li>
          </xsl:when>


          <xsl:when test="udt:Group='5'">
            <li style="padding: 0 0 15px 0;">
              <div style="font-size: 14px;">
                BRIDGE / CULVERT PROJECTS:
              </div>
              <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
              <xsl:if test="$currentData">
                <ul>
                  <xsl:apply-templates select="$currentData" mode="list">
                    <xsl:sort select="udt:Bid_x0020_Date_UDT_Value" order="ascending" />
                  </xsl:apply-templates>
                </ul>
              </xsl:if>
            </li>
          </xsl:when>


        </xsl:choose>
      </xsl:for-each>
    </ul>
  </xsl:template>


  <xsl:template name="EditLink">
    <xsl:if test="udt:EditLink">
      <a href="{udt:EditLink}">
        <img border="0" alt="edit" src="{//udt:Context/udt:ApplicationPath}/images/edit.gif" />
      </a>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>



 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListText Listing - Sort by valuesText Listing - Sort by values


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out