Copied to clipboard

Flag this post as spam?

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


  • Isis 21 posts 42 karma points
    Feb 06, 2012 @ 14:01
    Isis
    0

    Flatten node hierarchy in for-each selection

    Say I use the blogs package and wind up with a node hierarchy of something like this:

    Blog
      - DateFolder (for year)
        - DateFolder (for month)
          - DateFolder (for day)
            - BlogPost

    Then, using a custom XSLT to grab the 'latest' posts, how can I search the posts from the root node of the blog?

    As usual, I have tried many permutations of selection, but as of now I have this (which I assume should only need slight alteration?):

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1146)/descendant::BlogPost [@isDoc and string(umbracoNaviHide) != '1']">

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 06, 2012 @ 14:08
    Chriztian Steinmeier
    0

    Hi Grant,

    The XPath you're using should do exactly that (provided 1146 is the id of the Blog node and BlogPost is the DocumentType Alias of the posts).

    What are you getting?

    /Chriztian

     

  • Isis 21 posts 42 karma points
    Feb 06, 2012 @ 14:12
    Isis
    0

    I don't get anything at all. My container remains absolutely empty. (<div class="BlogContent"></div>).

  • Isis 21 posts 42 karma points
    Feb 06, 2012 @ 14:17
    Isis
    0

    As it happens, I was being stupid and not thorough - in my frantic messing with the XSLT to select appropriately (I never get it right first time!) I have the following line within the for-each:

    <xsl:if test="@nodeDocumentType = BlogPost">

    So, even though I had managed to alter my selection to be proper, I hadn't removed all traces of other 'modes' of selection. I'm not even sure this 'test' was itself correct (I know there is a @nodeSomethingOrOtherRelatedToType, but not sure DocumentType is it).

    Just pat the idiot on the back and move on. :/

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 06, 2012 @ 14:21
    Chriztian Steinmeier
    0

    Don't worry - it happens to all of us (not really, of course - just trying to consolate :-) (no, really, it does, Ed.)

    Another time, the test you tried to perform can be done with the self:: axis, like this:

    <xsl:if test="self::BlogPost">

    /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