Copied to clipboard

Flag this post as spam?

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


  • Ben Schlaepfer 74 posts 101 karma points
    Dec 02, 2013 @ 16:52
    Ben Schlaepfer
    0

    How to display all umbracoUrlAlias values from child nodes

    Hello Umbraco Community,

    I have a live site that uses umbracoUrlAlias to create direct access to products via a part number. The content tree structure reflects the full path to the product, the alias is 123-123-12

    E.g.

    http://www.coax-connectors.com/96-106G

    =

    http://www.coax-connectors.com/products/tooling/96-106g-non-ratchet-crimp-tool.aspx

    I've been maintaining a list of part numbers manually to enable a type-ahead search facility, but need to automate this now...

    To do this I need to pull a list of ALL umbracoUrlAlias values from a particular document type. That document type is two levels down from the location that I want to display the macro.

    Is this possible with XSLT ? I really just want to retrieve the value of that field where the document type has an alias of productPage ...

    Many thanks in advance for any light you can shed on this!

    Ben

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Dec 02, 2013 @ 17:00
    Chriztian Steinmeier
    1

    Hi Ben,

    Here's a quick macro that shows you how to go about something like this - heck, you could even use the uComponents RenderMacro control to render this as a "dashboard" property on any document type!

    <?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:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
        <!-- Grab all productPage documents -->
        <xsl:variable name="products" select="$siteRoot//productPage" />
    
        <xsl:template match="/">
            <ul>
                <xsl:apply-templates select="$products" />
            </ul>
        </xsl:template>
    
        <!-- Template for a productPage -->
        <xsl:template match="productPage">
            <li>
                Part number: <xsl:value-of select="umbracoUrlAlias" />, URL: <xsl:value-of select="umb:NiceUrl(@id)" />
            </li>
        </xsl:template>
    
    </xsl:stylesheet>
    

    /Chriztian

  • Ben Schlaepfer 74 posts 101 karma points
    Dec 02, 2013 @ 17:13
    Ben Schlaepfer
    0

    WOW!

    What a star - thanks Chriztian. I can definately work with that.

    Cheers

    Ben

Please Sign in or register to post replies

Write your reply to:

Draft