Copied to clipboard

Flag this post as spam?

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


  • anthony hall 222 posts 536 karma points
    Apr 24, 2018 @ 16:30
    anthony hall
    0

    Filtering Umbraco.MultiNodeTreePicker2 by doctype alias

    I have a MNTP that list my regions with the following xpath.

    "$site/configurationSettings/data/regions"
    

    i have 2 doctypes that can be added as children of "regions" these are "region" & "globalRegion".

    I'd like to be able to filter my xpath so that only "region" is displayed.

    I'm sure in the past i could use something like "//region" and all "region" on the tree would be return.

    Any ideas? 7.10.4

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Apr 24, 2018 @ 20:03
    Chriztian Steinmeier
    0

    Hi Anthony,

    Yes - the original MNTP in the older Umbraco versions was able (IIRC) to do that...

    Unfortunately, the XPath you enter for the current one is only for selecting the parent node (i.e. the one whose children should be selectable) - however, there should be an additional Allow items of type setting, where you could put the region alias in... ?

    Hope that helps,

    /Chriztian

  • anthony hall 222 posts 536 karma points
    Apr 25, 2018 @ 08:33
    anthony hall
    0

    Thanks Chriztian!

    Yeah true, i can at least limit the user to select the correct doctype. Ideally the user would just see a selection of items. As an alternative i could also filter by a property ("showInMntp"). It's hard finding workable examples?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Apr 25, 2018 @ 08:40
    Chriztian Steinmeier
    100

    Actually, I think you should take a look at the nuPickers collection of really awesome pickers.

    For your use-case, you could create a picker using the Xml CheckBox Picker which would render a list of checkboxes for each document matching an XPath, e.g.: $site/configurationSettings/data/regions/region[showInMntp = 1] - you can even use your own macro to render their labels...

    Or if it's a "pick only one" kind of picker, maybe use the Xml DropDown Picker ?

    Cheers, /Chriztian

  • anthony hall 222 posts 536 karma points
    Apr 25, 2018 @ 10:43
    anthony hall
    0

    Excellent suggestion. There is probably a cleaner query but following xpath works on the Xml CheckBox Picker

    $ancestorOrSelf/ancestor-or-self::home/configurationSettings/data/regions/region[showInMntp=1]
    

    Been meaning to explore this project for a while. I've ended up using the Dot Net Picker. Super simple setup.

    https://github.com/uComponents/nuPickers/wiki/Data-Source-DotNet

Please Sign in or register to post replies

Write your reply to:

Draft