Copied to clipboard

Flag this post as spam?

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


  • Lee 1123 posts 3059 karma points
    Aug 29, 2009 @ 12:47
    Lee
    0

    Get All Nodes With Specific Template

    Sorry I know this is going to be a simple one - But I need to get all nodes by a specific template where ever they are within the tree.  any chance of a syntax example

  • Bert 128 posts 251 karma points
    Aug 29, 2009 @ 13:11
    Bert
    1

    Is it by doctype or by template selected?

    doctype:

    $currentPage/ancestor-or-self::node [@nodeTypeAlias = 'yourdoctype alias']

    template:

    $currentPage/ancestor-or-self::node [@template = 'template id']
  • Chris Koiak 700 posts 2626 karma points
    Aug 29, 2009 @ 13:23
    Chris Koiak
    102
    $currentPage/ancestor-or-self::node//node [@template = 'template id']

    you may need to go to the top of the tree and traverse back down, as above.

  • Lee 1123 posts 3059 karma points
    Aug 29, 2009 @ 13:30
    Lee
    0

    Perfect - Thanks Chris, it was the syntax to go up and back down that I couldn't get right.

    Very appreciated, thanks

  • Bert 128 posts 251 karma points
    Aug 29, 2009 @ 13:33
    Bert
    1

    Indeed if you need the nodes from within the current tree, use Chris' solution.

    If you need to restrict the location from where your selection should start, add a level restrictment

    $currentPage/ancestor-or-self::node [@level=1]//node [@template = 'template id']
  • Lee 1123 posts 3059 karma points
    Aug 29, 2009 @ 13:56
    Lee
    0

    awesome thanks :)

  • 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