Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    May 24, 2011 @ 14:17
    Anthony Candaele
    0

    sorting links per country in xslt

    Hi,

    I'm currently implementing a Links page. The links shoud be listed and sorted by country.

    Therefore I created a Link Item document type, and I created a linkCountry datatatype of type uComponent Country Picker.

    Does anyone know how I can list the links per country?

    Something like this:

    Egypt
     link 1
     link 2
     link 3

    Iran
     link 1
     link 2
     link3

    etc...

    I already created a for-each loop that loops through alll links, but now I need to implement the sort by country:

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1' and string(linkCategory) = 'Links by country']">


    Does anyone knows how to do this with Xslt ?

    Thanks for your help,

    Anthony Candaele
    Belgium

  • Anthony Candaele 1197 posts 2049 karma points
    May 24, 2011 @ 16:28
    Anthony Candaele
    0

    I think the way to pull this off would be to loop through each country in the datatyp uComponents country picker, but the problem is that I don't know how to loop through each country in this datatype.

    anyone experience with this?

    greetings,

    Anthony

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 24, 2011 @ 19:06
    Tom Fulton
    2

    Hi Anthony,

    I think you actually want to Group the links by Country and not necessarily "sort" them, right?  If so you should look into Muenchian Grouping - there are a few threads here and there on the forums about it.

    The uComponents Country Picker just stores the country as a string so it should be pretty easy to group.  Here's a simple example that should get you going:

    <xsl:key name="country" match="Link [@isDoc]" use="linkCountry"/> 
        
    <xsl:template match="/">
      <xsl:apply-templates select="$currentPage/Link [generate-id() = generate-id(key('country', linkCountry)[1])]" mode="country"/>
    </xsl:template>

    <xsl:template match="Link [@isDoc]" mode="country">
      <h2><xsl:value-of select="linkCountry"/></h2>
      <xsl:apply-templates select="$currentPage/Link [linkCountry = current()/linkCountry]" mode="link"/>
    </xsl:template>
        
    <xsl:template match="Link [@isDoc]" mode="link">
      - <xsl:value-of select="@nodeName"/><br/>
    </xsl:template>

    Also, a side note, one caveat I ran into with the uComponents Country Picker is it doesn't seem to list all countries (for me anyway), some missing are China, Aruba,  Anguilla, Fiji, etc.  I posted a workitem here.

    Hope this helps,
    Tom

  • Anthony Candaele 1197 posts 2049 karma points
    May 25, 2011 @ 11:26
    Anthony Candaele
    0

    Hi Tom, I added a comment to your workitem on Codeplex and I voted for your workitem

    I found another missing country: Sudan

    I would be nice if there was some workaround to add missing countries to the uComponent Country Picker

    greetings,

    Anthony

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 25, 2011 @ 14:16
    Tom Fulton
    0

    FYI, as a workaround I just imported the countries into a DB table from here and used something like Tim's Database driven dropdown list datatype

Please Sign in or register to post replies

Write your reply to:

Draft