Copied to clipboard

Flag this post as spam?

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


  • Paul A 133 posts 368 karma points
    Mar 11, 2011 @ 09:35
    Paul A
    0

    Get nodes with certain parent node ultimate picker value

    Hi,

    I'm using ultimate picker to categorise 'project' nodes. 'Projects' have child nodes of varying types, one of which is 'video'. I'd like to get the latest video posted in a certain category. Any help/links muchly appreciated.

    A

     - B

     - - C

     - - C

     - B

     - - C

     - B

     - - C

     - - C

    'A' is the parent node of all projects. 'B's are the projects (with ultimate picker 'category' values). 'C's are the videos. I need latest C where B ultimate picker has category X. Hope that makes sense!

    Thanks,

    Paul

  • Paul A 133 posts 368 karma points
    Mar 11, 2011 @ 23:12
    Paul A
    0

    Ah, got it after some head scratching. XSLT isn't my strong point to let me know if I'm doing something that's bad practise. Hope this helps someone else:

    <xsl:variable name="allProjectsInCountry" select="umbraco.library:GetXmlNodeById($parentNodeOfProjects)/Project[@isDoc][contains(concat(',',
     countries, ','), concat(',', string($currentPage/@id), ','))]" />
      <xsl:variable name="allVideosInCountry" select="$allProjectsInCountry/FeaturedVideo" />
      

      <xsl:for-each select="$allVideosInCountry">
        <xsl:sort select="@id" order="descending" />

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 12, 2011 @ 21:11
    Chriztian Steinmeier
    0

    Hi Paul,

    Just two things: You almost never need to explicitly cast anything in XSLT - so you can get rid of the string() function around $currentPage/@id inside the concat() function - that happens automatically, and not having to wrap that around helps the readability;

    You say you want the latest FeaturedVideo, so I'd suggest you sort using either @createDate or @updateDate - they are XMLDates which are just text, but in a sortable format. You should not rely on the highest @id to be the latest node.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft