Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Dec 19, 2011 @ 17:16
    trfletch
    0

    Property dropdown populates another dropdown based on selection

    Hi All,

    I have an umbraco 4.5 website. I need to have a dropdown list property on a document type called "Category" where a user can select what category the node is in. The dropdown needs to be populated from certain nodes in my tree (ones that are of document type "Category" and "sub-category"), my tree looks like this:

    Home (doc type = homepage)
    News (doc type = category)
    - Politics (doc type = sub-category)
    - Business (doc type = sub-category)
    Sport (doc type = category)
    - Football (doc type = sub-category)
    - Rugby (doc type = sub-category)
    - Cricket (doc type = sub-category)
    About Us (doc type = textpage)
    Contact Us (doc type = textpage)
    Articles ***This is where all my articles are stored***

    What I did look at using was the Ultimate Picker datatype but the issue I have is that user has to pick a sub-category and there is no way I can see using the ultimate picker that I can force this, for example there is nothing stopping them select "News" or "Sport" from the dropdown.

    This has led me to believe that the only way I am going to be able to achieve this is to have a dropdown list property called "Category" that would list "News" and "Sport" then when you selected a value for example "News" this would populate another dropdown list called "Sub-category" with "Politics" and "Business". I could then make this "Sub-category" dropdown mandatory.

    Can someone please give me any suggestions as to how I can achieve this? Are there any custom packages or properties available to do this or am I going to have to get one written?

    Just as a side note, my articles cannot be stored under their relevant sub category node for other reasons which is why I have this issue.

     

     

  • Rich Green 2246 posts 4008 karma points
    Dec 19, 2011 @ 19:02
    Rich Green
    1

    Hi,

    You can use the uComponents Multi Node Tree Picker http://ucomponents.codeplex.com/wikipage?title=MultiNodeTreePicker&referringTitle=Documentation

    Essential in my opinion for every Umbraco site.

    Rich 

  • trfletch 598 posts 604 karma points
    Dec 20, 2011 @ 10:55
    trfletch
    0

    Hi Rich,

    Thank you for this, it looks like it should do exactly what I want. The only problem is I am having a couple of issues with the XPath getting it to only show and allow me to the select the nodes that I want (i.e. only show "Categories" and "sub-categories" but only allow "sub-categories" to be selected). So far I have tried the following XPATH:

    ancestor-or-self::* [@isDoc][name()='Website']/*[name()='Category']

    But this then just only shows:

    News (doc type = category)
       - Politics (doc type = sub-category)
       - Business (doc type = sub-category)

    Hoping that this is someone quite simple that I am missing!

    The other issue is if I try to Disable someone selecting the "Category" nodes by adding the following XPATH in the XPATH filter:

    [name()='Category']

    Then I get the following error next to each sub-category node on the Multi Node Picker property: uComponents: XPath Error!

    Any ideas how I can get around these two issues?

  • Rich Green 2246 posts 4008 karma points
    Dec 20, 2011 @ 11:00
    Rich Green
    1

    Hi,

    The MultiNodeTreePicker does not hide nodes, although you can set the start path (so the user will only see nodes underneath the start node).

    To filter nodes you can just use

    DocType1 |  DocType2  | DocType3 

    In your Xpath filter.

    Hope this helps

    Rich

  • trfletch 598 posts 604 karma points
    Dec 20, 2011 @ 12:35
    trfletch
    0

    Hi Rich,

    Thanks that is excellent. This is now working perfectly. I can live with the fact that I can see the other nodes because I cannot select them using the XPath filter so that is good enough.

    Just for anyone that wanted to know I used the following XPath to show my whole tree (my top level nodetype is "Website"):

    ancestor-or-self::* [@isDoc][name()='Website'] 

    And the following XPath filter set to enabled to only allow sub-categories to be selected:

    Sub-category 

    Regards
    Tony

     

  • trfletch 598 posts 604 karma points
    Dec 20, 2011 @ 13:00
    trfletch
    0

    Sorry scrap what I said above about using the XPath to show my whole tree, this did work fine until I created a new document and this would not show anything (for obvious reasons). I therefore changed it to:

    Node selection type = Node picker
     
    And selected my top level node
     
  • 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