Copied to clipboard

Flag this post as spam?

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

  • Patrick 33 posts 82 karma points
    Aug 04, 2011 @ 12:35

    Other document type through XSLT


    I am using Umbraco for a couple of days now and see the potential but got stuck on the following:

    In the content section I made two nodes, one for my navigation and subnavigation and another one for banners.

    These banners consist of an image and a title and will eventually lead towards a textpage. I want these banners to be shown on every page, here is where my problem starts.

    I made my document type, my template and xslt, but the xslt examples I've seen all wat to approach data through the current page, I don't need/want to do this as my data needs to come from a different document type.

    Is it possible to do something like:

    <xsl:for-each select="documenttype">

    Maybe my thoughts are completely wrong, but being new to this any help or reference towards howto-documents is welcome.

    Greetings, Patrick

  • Tom Fulton 2030 posts 4997 karma points c-trib
    Aug 04, 2011 @ 13:57
    Tom Fulton

    Hi Patrick

    $currentPage is just a starting point, you can use it to access other pages outside of it by using different axes (see XPath Axes Visualizer to see how this works)

    If your structure is like:

    - Root (Content)
    - - Page
    - - - Page
    - - Page
    - - Banners  (Doctype: Folder-Banners)
    - - - Banner1  (Doctype: Banner)

    You can use the below to traverse to the root, then to the Banners folder & each banner inside

    <xsl:for-each select="$currentPage/ancestor-or-self::root/Folder-Banners/Banner">

    Also if your Banners can be in different areas of the site and you're not sure where, you can use the below to get all banners beneath the root - though the above is probably better performing.

    <xsl:for-each select="$currentPage/ancestor-or-self::root//Banner">

    Hope this helps,

  • Patrick 33 posts 82 karma points
    Aug 04, 2011 @ 14:48

    Thanks Tom, this certainly helps!


Please Sign in or register to post replies

Write your reply to: