Copied to clipboard

Flag this post as spam?

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


  • Garrett Fisher 341 posts 496 karma points
    Oct 10, 2012 @ 18:23
    Garrett Fisher
    0

    Multiple Root Nodes: How to Select Nodes Under ONLY Current Root

    Hi--

    I've got a multilanguage site with multiple root nodes, but in several places in my XSLT I am using something like this:

    umbraco.library:GetXmlAll()//BlogCategory[not(umbracoNaviHide = 1)]

    ...to select all nodes of a certain type.  However, what is happening as you can imagine is that it is returning all nodes of type BlogCategory from under ALL the separate sites / root nodes.  How can I select all nodes of this type WHOSE ROOT node has a certain property, for example, [language = 'DE'] or whatever, or even better, without specifying a property value.  I just want to stay in the current set of nodes, the current 'site', and not branch out and over everything.

    Help?

    Thanks in advance,

    Garrett

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 10, 2012 @ 19:00
    Tom Fulton
    1

    Hi Garrett,

    It's probably best to walk up to the root of your "current site" instead of getting all the XML.  You could do:

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::Site [@isDoc]"/>  <!-- (replace Site with the doctype alias of your site's root node) -->
    <xsl:variable name="blogCategories" select="$siteRoot//BlogCategory [@isDoc][not(umbracoNaviHide) = 1]" />

    Also as a side note, using //BlogCategory probably isn't very efficient as its searching through every single descendant node.  It's much better if you know where these will be to provide a more specific query, such as

    <xsl:variable name="blogCategories" select="$siteRoot/Home [@isDoc]/Blog[@isDoc]/BlogCategory [@isDoc][not(umbracoNaviHide) = 1]" />

    Hope this helps,
    Tom 

  • Garrett Fisher 341 posts 496 karma points
    Oct 10, 2012 @ 19:29
    Garrett Fisher
    0

    That was great advice -- thanks a lot, Tom!

    //Garrett

     

  • 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