Copied to clipboard

Flag this post as spam?

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


  • MikeD 92 posts 112 karma points
    Jul 16, 2012 @ 16:23
    MikeD
    0

    Looping through Checkbox List

    I am having some trouble with a page on my clients new site.  Hopefully I can explain what is supposed to happen clearly enough that someone can see why it's not working.

    I have a chackbox list on each bio page.  This is a list of schools the person attended.  On the display page, I want to list the schools, and under each school, list the people who attended that school.

    Here is a link to my working page.  I can get the first school on the list to work, but not the rest.  I cannot figure out what I am doing wrong: http://dev.watkinseager.com/schools.aspx

    Please keep in mind I am kinda new to XSLT, so please don't laugh too hard at my code.... here is the code from schools.xslt:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="nodeid" select="1061" />
    <xsl:template match="/">
      <div>
        <xsl:call-template name="ListAllSchools" />
      </div>
    </xsl:template>

    <xsl:template name="ListAllSchools">
      <xsl:variable name="AllSchools">
        <xsl:for-each select="umbraco.library:GetPreValues(1069)//preValue">
          <xsl:value-of select="." />`
        </xsl:for-each>
      </xsl:variable>
      <xsl:variable name="SchoolListArray" select="umbraco.library:Split($AllSchools,'`')" />
        <xsl:for-each select="$SchoolListArray//value">
          <xsl:variable name="SchoolName" select="." />
          <xsl:if test="$SchoolName != ''">
            <xsl:for-each select="$SchoolName">
            <class="SpecTitle"><xsl:value-of select="$SchoolName" /></p>
              <xsl:call-template name="ListAttorneys">
                <xsl:with-param name="SchoolName" select="$SchoolName"/>
              </xsl:call-template>
            </xsl:for-each>
          </xsl:if>
      </xsl:for-each>

    </xsl:template>

    <!-- The problem is in this template -->
    <xsl:template name="ListAttorneys">
      <xsl:param name="SchoolName"/>
    <!--
     >>> <xsl:value-of select="$SchoolName" />
    -->
      <xsl:for-each select="umbraco.library:GetXmlNodeById($nodeid)/*[@isDoc and string(umbracoNaviHide) != '1']">
        <xsl:variable name="thisAttorneysSchools" select="umbraco.library:Split(schools,',')" />
        <xsl:variable name="thisAttorneysFirstName" select="attorneyFirstName" />
        <xsl:variable name="thisAttorneysLastName" select="attorneyLastName" />
        <xsl:variable name="MySchoolName" select="$thisAttorneysSchools//value" />
        <xsl:if test="$MySchoolName = $SchoolName ">
         <xsl:value-of select="$thisAttorneysFirstName" /> <xsl:value-of select="$thisAttorneysLastName" /><br />
        </xsl:if>

      </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

    Thanks in advance for any help you guys might be able to provide,

    Mike D

  • MikeD 92 posts 112 karma points
    Jul 17, 2012 @ 18:30
    MikeD
    0

    Trying to edit my post to show updated (and much cleaner) code... 

    <xsl:param name="currentPage"/>
    <!-- The nodeID of the Parent node -->
    <xsl:variable name="nodeid" select="1061" />

    <!-- get all the prevalues from the "schools" checkbox dataype -->
    <xsl:variable name="AllSchools">
      <xsl:for-each select="umbraco.library:GetPreValues(1069)//preValue">
        <xsl:value-of select="." />`
      </xsl:for-each>
    </xsl:variable>

    <!-- create an array of all the school names -->
    <xsl:variable name="SchoolListArray" select="umbraco.library:Split($AllSchools,'`')" />

    <xsl:template match="/">
      <div>
        <xsl:for-each select="$SchoolListArray//value">
          <xsl:variable name="SchoolName" select="." />
          <xsl:if test="$SchoolName != ''">
            <class="SpecTitle"><xsl:value-of select="$SchoolName" /></p>
              <xsl:call-template name="ListAttorneys">
                <xsl:with-param name="ThisSchoolName" select="$SchoolName"/>
              </xsl:call-template>
          </xsl:if>
      </xsl:for-each>
      </div>
    </xsl:template>

    <!-- The problem is in this template -->
    <xsl:template name="ListAttorneys">
      <xsl:param name="ThisSchoolName"/>

      <xsl:for-each select="umbraco.library:GetXmlNodeById($nodeid)/* [contains(schools,$ThisSchoolName ) and @isDoc and string(umbracoNaviHide) != '1']">
        <xsl:value-of select="attorneyFirstName" /> <xsl:value-of select="attorneyLastName" /><br />
      </xsl:for-each>

    </xsl:template>


  • MikeD 92 posts 112 karma points
    Jul 18, 2012 @ 20:15
    MikeD
    0

    Figured it out (with help)

    <xsl:variable name="AllSchools">
      <xsl:for-each select="umbraco.library:GetPreValues(1069)//preValue">
        <xsl:value-of select="." />`
      </xsl:for-each>
    </xsl:variable>

     

    should be

    <xsl:variable name="AllSchools">
      <xsl:for-each select="umbraco.library:GetPreValues(1069)//preValue">
        <xsl:value-of select="." />`</xsl:for-each>
    </xsl:variable>

Please Sign in or register to post replies

Write your reply to:

Draft