Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Oct 18, 2011 @ 16:16
    Bex
    0

    Get all Nodes By DocumentType

    Hi 

     

    I'm trying to loop all nodes by a document type in xslt.
    I have come across this a few times in the forum but nothings working for me.

    My documents could be anywhere in the system and as far as I can gather this should work:

      <xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='prop'] ">

    But it doesn't.

    Can I even do what I am trying to do?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 18, 2011 @ 16:30
    Tom Fulton
    0

    Are you using the new XML schema?  Your example above looks like it's referencing the old schema.

    If using the new schema instead try: 

      <xsl:for-each select="umbraco.library:GetXmlAll()//prop [@isDoc] ">

    Not sure if this is the most efficient way but should work

    -Tom

  • Bex 444 posts 555 karma points
    Oct 18, 2011 @ 16:37
    Bex
    0

    I've got the latest version of umbraco so it's what ever the lastest schema is.. I know it changed at some point but am unsure when.

    Can you think of another way of doing this?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 18, 2011 @ 16:38
    Tom Fulton
    0

    You should be using the new schema then.  Did you try the above code?  Is 'prop' the alias of the Document Type you are looking for?

    You could also try:  $currentPage/ancestor::root//prop [@isDoc]

    -Tom

  • Bex 444 posts 555 karma points
    Oct 18, 2011 @ 16:40
    Bex
    0

    Yes.. the above code works well! You just mentioned that possible not efficient !

    Prop is the documenttype. 

    Will this find the files in the recycling bin as I know this has been a problem in the past?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 18, 2011 @ 16:45
    Tom Fulton
    0

    Not sure about GetXmlAll, but the second snippet I pasted shouldn't show items in the recycle bin.  If it does you could add a check, something like:  ...//prop [@isDoc][not(contains(@path, '-20,'))] but I don't think it will be an issue.

    -Tom

  • Bex 444 posts 555 karma points
    Oct 18, 2011 @ 17:03
    Bex
    0

    Thanks for your help :)

Please Sign in or register to post replies

Write your reply to:

Draft