Copied to clipboard

Flag this post as spam?

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


  • Jon Behrens 53 posts 77 karma points
    Jun 15, 2010 @ 00:30
    Jon Behrens
    0

    How to select nodes in a different branch of the document tree

    Hello,

    I've got a document tree with two branches, one for people and one for projects.

    Projects are associated with people, but are not subordinate to them. When I display a people page, I want also to show all of that person's associated projects. I tried using

    umbraco.library:GetXmlNodeByXPath('/root/node[@nodeTypeAlias="project"]')

    and then filter that list for people, but the list comes back empty. I think it is because the query is being executed in the context of currentPage which does not contain projects.

    How do I get a list of nodes in a different branch of the document tree?

    Thanks, Jon

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jun 15, 2010 @ 00:35
    Chriztian Steinmeier
    0

    Hi Jon,

    If "people" and "projects" are in the Umbraco Content tree (and published) they should be available through an XPath from $currentPage, e.g.:

    <xsl:variable name="allProjects" select="$currentPage/ancestor-or-self::root//node[@nodeTypeAlias = 'project']" />

    The above would collect all project nodes in the variable - it's inefficient because of the double slash (descendant::) axis, but should let you confirm they're there.

    /Chriztian

  • Jon Behrens 53 posts 77 karma points
    Jun 15, 2010 @ 00:52
    Jon Behrens
    0

    Thanks, that solved it.

  • Arnt Grøstad 29 posts 49 karma points
    Nov 10, 2010 @ 07:27
    Arnt Grøstad
    0

    Hi there.
    Im trying to get an usercontrol (.net) c# to iterate thru total content tree and find me a page that have the property (alias=MyDistinctPage, value=1stUserHomePage)
    There ar ONLY one page in content tree that matches this alias/value.

    My suggestion:

     

     

    XPathNodeIterator it = umbraco.library.GetXmlNodeByXPath("//node[(./data[@alias='MyDistinctPage' and text()='1stUserHomePage'])]");
    Sad to say, I get noting back, nada, zip.

    Any...ideas? :)

  • Arnt Grøstad 29 posts 49 karma points
    Nov 10, 2010 @ 09:38
    Arnt Grøstad
    0

    Dropped it.
    After several tries, I just went:

    foreach

     

     

    (umbraco.cms.businesslogic.web.Document pages in Document.GetDocumentsOfDocumentType(myDocTypeID))

     

     

    Then i if'ed pages.getProperty("PropIWantet").value.
    Taataa

     

Please Sign in or register to post replies

Write your reply to:

Draft