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 ListHelp With XSLT FileHelp With XSLT File
Previous
 
Next
New Post
4/26/2012 10:47 AM
 

I am not familiar with XSLT very well, and I need help modifying our current XSLT file.

Current Table Structure:
1) Group (Text)
2) Name (Text)
3) Title (Text)
4) EMail (Text)
5) Phone (Text)
New Table Structure:
1) GroupOrderIndex (Integer)
2) Group (Text)
3) OrderIndex (Integer)
4) FirstName (Text)
5) LastName (Text)
6) Title (Text)
7) EMail (Text)
8) Phone (Text) 

Sample Data (Using New Table Structure):

1 Administrators 1 Mary Smith Division Coordinator Someone@somewhere.com 123-456-7890
1 Administrators 2 John Delay Dept. Head Someone@somewhere.com 123-456-7890
1 Administrators 2 Mike Kelly Dept. Head Someone@somewhere.com 123-456-7890
2 Network Support 1 Mike Graff Specialist Someone@somewhere.com 123-456-7890
2 Network Support 1 Bob McDonald Specialist Someone@somewhere.com 123-456-7890
2 Staff Developers 1 Michelle Zane Trainer Someone@somewhere.com 123-456-7890
2 Staff Developers 1 George Ford Trainer Someone@somewhere.com 123-456-7890

 

Currently my script groups by "Group", and then displays the data using the defined template.
I am changing the structure to split the "Name" into "First" and "Last" and I am adding an "OrderIndex" field.

I need to do the following:
1) Group by "GroupOrderIndex, Group" and then sort by "OrderIndex, Lastname, FirstName". 
2) When displaying the name I need to concatanate FirstName and LastName into one column

Can someone help me modify my current XSLT to do this?



<?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">
    <tr class="Normal">
      <td>
        <xsl:call-template name="EditLink" />
      </td>
      <td Width="200px">
        <xsl:value-of select="udt:Name" disable-output-escaping="yes" />
      </td>
      <td Width="300px">
        <xsl:value-of select="udt:Title" disable-output-escaping="yes" />
      </td>
      <td Width="20px" />
      <td>
        <xsl:value-of select="udt:EMail" disable-output-escaping="yes" />
      </td>
      <td>
        <xsl:value-of select="udt:Phone" disable-output-escaping="yes" />
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="/udt:UserDefinedTable">
    <table Width="100%" style="border-collapse:collapse;">
      <xsl:for-each select="udt:Data[count(. | key('data-by-group', udt:Group)[1]) = 1]">
        <xsl:sort select="udt:Group" />
        <xsl:variable name="currentData" select="key('data-by-group', udt:Group)" />
        <xsl:if test="$currentData">
          <tr style="border-bottom-width:thin;border-bottom-style:dashed;font-weight:bold">
            <td colspan="5" Height="28px" Style="vertical-align:bottom">
              <xsl:value-of select="udt:Group" disable-output-escaping="yes" />
            </td>
          </tr>
          <tr class="Normal" style="font-weight:bold">
            <td />
            <td>Name</td>
            <td>Title</td>
            <td />
            <td>E-Mail</td>
            <td>Phone</td>
          </tr>
          <xsl:apply-templates select="$currentData" mode="list">
          </xsl:apply-templates>
        </xsl:if>
      </xsl:for-each>
    </table>
  </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>


Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
4/26/2012 2:10 PM
 
The answer for 2) is to use a calculated column "Name" and to concat first name and last name within. This requires no changes to XSLT
 
New Post
4/26/2012 2:21 PM
 

For 1), change <xsl:sort select="udt:Group" /> 
 to <xsl:sort select="concat(udt:GroupOrderIndex,udt:Group)" /> 

add a <xsl:sort >statement inside xsl:applytemplates. 

For more information, check http://www.w3schools.com/xsl/el_sort.asp 


 
New Post
4/26/2012 5:03 PM
 
Thank you! Took me a bit to tweak but worked perfectly in the end!

Thanks again!

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListHelp With XSLT FileHelp With XSLT File


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