Copied to clipboard

Flag this post as spam?

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


  • Mads Sørensen 188 posts 433 karma points
    Mar 23, 2016 @ 12:39
    Mads Sørensen
    0

    Multinode treepicker - Xpath query - better documentation?!?

    Hi guys I'm trying to understand how the "Query for root node with xpath" function works. And i think that the documentation is not very

    But dont have any clue?!?

    My site tree looks like this:

    www.homepage.dk
     -Afdelinger (Doctype: Afdelinger)
     --Kolding (Doctype: Afdeling)
       ---Medarbejder 01 (Doctype: Ansat)
       ---Medarbejder 02 (Doctype: Ansat)
       ---Medarbejder 03(Doctype: Ansat)
     --Odense (Doctype: Afdeling)
       ---Medarbejder 04 (Doctype: Ansat)
       ---Medarbejder 05 (Doctype: Ansat)
       ---Medarbejder 06 (Doctype: Ansat)
    

    What I want is to show all the (Doctype: Ansat) nodes in the treepciker.

    By razor i would do something like this:

    CurrentPage.AncestorOrSelf(1).Descendants("Ansat")
    

    But i have no clue how to do it with the xpath?!?

    Any help would be nice :D

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 23, 2016 @ 13:00
    Alex Skrypnyk
    0

    Hi Mads,

    Can you try like :

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <xsl:for-each select="$siteRoot/Ansat">
    </xsl:for-each>
    

    Thanks, Alex

  • Mads Sørensen 188 posts 433 karma points
    Mar 23, 2016 @ 13:30
    Mads Sørensen
    0

    Hi alex, the problem is not code it self but the settings in the backoffice.enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 23, 2016 @ 17:00
    Alex Skrypnyk
    0

    Mads, maybe you need to use 2 slashes ?

    $root//Afdelinger 
    
  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 23, 2016 @ 18:13
    Bjarne Fyrstenborg
    0

    Hi Mads

    How about a more site specific xpath query?

    $site/Afdelinger/Afdeling
    

    $site is the ancestor at level 1. / means children and // means descendants.

    So you could also use this query if "Afdeling" exists at deeper levels.

    $site/Afdelinger//Afdeling
    

    I prefer to use English terms for aliases in general, but you can of course use Danish terms if you like - æ, ø, å and other special characters are automatically replaced.

    Furthermore the config property "Allow items of type" should not be "Medarbejder" but "Ansat" (alias of the document type you want to pick).

    /Bjarne

  • Mads Sørensen 188 posts 433 karma points
    Mar 24, 2016 @ 10:48
    Mads Sørensen
    0

    Hi Bjarne - great description.

    Sorry for my switching around ind doctypes :P

    What I want is to get a complet list of all my nodes with the doctype of "medarbejder".

    So i tried to do this:

    $site//medarbejder
    

    But this gives me nothing ?!?

    But if i understod your description , this xpath query should mean something like this(in razor):

    AncestorOrSelf(1).Descentants("medarbejder")
    

    Wich result in alle descendants with the doctype of "medarbejder" would be listed?!?

    So what am I doing wrong?!?

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 24, 2016 @ 11:21
    Bjarne Fyrstenborg
    0

    Hi Mads

    Yes, in the razor expression you select all descendant nodes of type "medarbejder".

    But in MNTP you choose a type "Content", "Media" or "Member" .. then you can choose a start node id (otherwise it will use -1, which is root id).

    You can select a start node id by using the tree picker or specifying a xpath expression.

    So, what you want when using xpath is to find parent id of "medarbejder" nodes. If this parent has different types of children, you can also use the filter option to only list specific nodes matching a document type alias.

    Your parent document type is "Afdeling".

    $site//Afdeling
    

    or

    $site/Afdelinger/Afdeling
    

    /Bjarne

  • Mads Sørensen 188 posts 433 karma points
    Mar 24, 2016 @ 15:48
    Mads Sørensen
    0

    So no chance for selecting all descendants when they are spread out in multiple folders?!?

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 24, 2016 @ 18:58
    Bjarne Fyrstenborg
    0

    No, I think the MNTP only select the first of the descendants and use that as start node id. E.g. in Fanoe starterkit if I specify LandPage as start node it will be the first of the LandingPage node and therefore only the children of this node.

    E.g. this xpath expression:

    $site/descendant-or-self::LandingPage
    

    make this request:

    /umbraco/backoffice/UmbracoTrees/ApplicationTree/GetApplicationTrees?application=content&tree=content&isDialog=true&startNodeId=1064
    

    so I can only select the first 3 textpage nodes. I have to make Home or root as start node and then filter document types to only "TextPage".

    Listview has same issue if I set it as start node as listview node isn't shown and therefore no search box to search for the children.

    I had a case to pick reviews in listview, but didn't want the entire site tree just to pick specific review nodes in listview, so we made a custom search for listview nodes using Web API and Examine - it also made in possible to show more details of each node than the tree expose via the entity and search services.

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/76057-return-camelcase-property-names-from-api-controller

    /Bjarne

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 24, 2016 @ 19:03
    Bjarne Fyrstenborg
    0

    Oh, by the way.. I just remembered the great Mr N Picker: https://our.umbraco.org/projects/backoffice-extensions/mr-n-picker/

    It does exactly what you are looking for - supports multiple root nodes.

    /Bjarne

  • karen 186 posts 461 karma points
    Apr 20, 2016 @ 20:23
    karen
    0

    HI, I see this question is a few weeks old, but still marked as unsolved, so giving you my solution. I had to do something similar, be able to pick news items from any site (multi sites on the instance) using the MNTP

    My content tree is like:

    Content
    - Site1
     -- News
      ---News Item 1
      ---News Item 2
    -Site2
     -- News
      --- News Item 1
      --- News Item 2
    

    to start at the root, my 'XPath expression' is

    $ancestorOrSelf/ancestor-or-self::root
    

    and then 'XPath filter' is just the document type.

    So then I can pick any news item from Site 1, Site 2 etc.

    I am using 6.x but I think should work the same in 7?

    Your tree picker unfortunately shows EVERYTHING in the tree, you just can't pick them (maybe this is different in 7?)

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft