Copied to clipboard

Flag this post as spam?

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


  • ChristophC 22 posts 61 karma points
    May 29, 2010 @ 12:56
    ChristophC
    0

    Grouping pages with their children-pages

    Ok, my Content looks like this:

     

    Content

    Places

    City1

    Employees

    Management

    Employee1

    Employee2

    Administration

    Employee3

    Employee4

    Contact

    Way to us

    City2

    Employees

    ...

    What I want to do on each City-Page (City1, City2, ...), is to show each Employee grouped by their business area (Management, Administration, etc):

    City1

    Management:

    Employee1

    Employee2

    Administration:

    Employee3

    Employee4

    ...

    How can I solve this via XSLT???

     

    Thanks for your answers!

     

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 29, 2010 @ 17:56
    Chriztian Steinmeier
    0

    Hi Christoph,

    This should get you going - assuming $currentPage is the "City" node, you can use the following XSLT in a macro to get started:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        exclude-result-prefixes="umb"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <xsl:template match="/">
            <xsl:apply-templates select="$currentPage" />
        </xsl:template>
    
        <!-- Template for $currentPage -->
        <xsl:template match="node[@nodeTypeAlias = 'City']">
            <h1><xsl:value-of select="@nodeName" /></h1>
    
            <h2>Management</h2>
            <ul>
                <xsl:apply-templates select="node[@nodeName = 'Employees']/node[@nodeName = 'Management']/node" />
            </ul>
    
            <h2>Administration</h2>
            <ul>
                <xsl:apply-templates select="node[@nodeName = 'Employees']/node[@nodeName = 'Administration']/node" />
            </ul>
        </xsl:template>
    
        <!-- Template for a single employee -->
        <xsl:template match="node[@nodeTypeAlias = 'Employee']">
            <li>
                <xsl:value-of select="@nodeName" />
            </li>
        </xsl:template>
    
    </xsl:stylesheet>
    

    (There's a couple of assumptions - e.g., that city nodes have an alias of "City" and that employee nodes have the alias "Employee", but you should be able to make the necessary changes yourself, if needed.) 

    /Chriztian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies