Copied to clipboard

Flag this post as spam?

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


  • Connie DeCinko 931 posts 1160 karma points
    Mar 08, 2011 @ 17:53
    Connie DeCinko
    0

    Grouping for Repeated Content

    I am trying to group my output from a Repeated Custom Content data type.  I get results, but with duplicates as I don't appear to be specifying the key correctly.  Any help would be appreciated.

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

    <xsl:param name="currentPage"/>

    <xsl:key name="candidates-by-district" match="item" use="district" />

    <xsl:template match="/">
      
      <xsl:for-each select="$currentPage/candidates/items/item [count(. | key('candidates-by-district', district)[1]) = 1]">

        <xsl:sort select="district" order="ascending"/>
        
        <h3><xsl:value-of select="umbraco.library:GetPreValueAsString(./data [@alias='district'])" /></h3>
        

      </xsl:for-each>

    </xsl:template>
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 08, 2011 @ 18:38
    Chriztian Steinmeier
    0

    Hi Connie,

    You seem to be mixing the old XML Schema with the new one - the GetPreValueAsString() gets its value from an old-style data[@alias = 'district'] property, whereas the key() fetches item nodes based on the new-style district property... so which is it? :-)

    /Chriztian 

     

  • Connie DeCinko 931 posts 1160 karma points
    Mar 08, 2011 @ 18:41
    Connie DeCinko
    0

    I'm running the new schema but Repeatable Custom Content was never truely updated for 4.5 so still uses the old schema.  That's why the mixture.

     

  • Connie DeCinko 931 posts 1160 karma points
    Mar 08, 2011 @ 18:43
    Connie DeCinko
    0

    I think you hit it on the head...  because RCC still uses the old format, I have to refer to district via that old format:

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

    <xsl:param name="currentPage"/>

    <xsl:key name="districts" match="item" use="./data [@alias='district']" />

    <xsl:template match="/">
      
      <xsl:for-each select="$currentPage/candidates/items/item [count(. | key('districts', ./data [@alias='district'])[1]) = 1]">

        <xsl:sort select="district" order="ascending"/>
        
        <h3><xsl:value-of select="umbraco.library:GetPreValueAsString(./data [@alias='district'])" /></h3>
        

      </xsl:for-each>

    </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft