Nibble

New Package - Ultimate Picker

The ultimate picker is a new datatype which will be a default datatype in umbraco v4. But I decided to also package this up so it could be used in lower versions.

Basically it’s about combining a datasource (umbraco node, content or media) with a control (AutoComplete, CheckBoxList, DropDownList, ListBox and RadioButtonList).

After installing the package. You’ll have to create a new datatype and choose ‘ultimate picker’ as the rendercontrol.

image

So the configurations options are:

Database datatype: In wich field the value will be saved

Type: type of control that will be shown, you can choose from AutoComplete, CheckBoxList, DropDownList, ListBox and RadioButtonList

Parent nodeid: the nodeid to use, the descendants will be the nodes you can choose from, this can be a contentnode or a medianode

Show grandchildren: check this if you want to include all descendants, not only the direct children of the parent node.

After configuration it’s ready to be used as a property on a document type.

 

Picker in action:

image

Parent nodeid is set the id of container.

CheckBoxList (can select multiple nodes)

image

DropDownList (will save 1 selected node)

image

ListBox (can select multiple nodes)

image

RadioButtonList (one node)

image

AutoComplete (one node)

image

The picker will save the nodeid’s, in cause of multiple selected values this will be a comma seperated list of nodeid’s.

Ultimate Picker: download

19 Comments so far

  1. Kenneth Solberg on July 20th, 2008

    Excellent work Tim - two thumbs up!

  2. Jon Cuthbert on July 20th, 2008

    This is perfect, the exact missing piece I wanted in Umbraco! Thanks.

  3. Greg on July 21st, 2008

    Awesome! can’t wait to try it out :)

  4. Petr Snobelt on July 21st, 2008

    Hi, nice control.

    2 suggestions:
    Allow add restrictions to selectable document type

    Allow dynamic parentnode id (for example by level). When creating multi-lang sites, I don’t want allow users to pick node from different language.

    Thanks Petr

  5. Ismail Mayat on July 21st, 2008

    Tim,

    Great work. I really like the autocomplete selector thats uber cool, i have found that most editors sort of know what they are looking for by title / keyword so its way quicker to type and find that traverse a tree!

    Regards

    Ismail

  6. Mikkel Keller on July 29th, 2008

    Hi Tim

    This is really great. This functionality can be used extensively when relating content. I made a way simpler version for http://suzuki.dk to relate cars, models, motors etc. My datatype selected the parent node based on an XPath query on the content tree instead of the nodeId. This way you’ll be able to select different parent nodes in different contexts (eg. when creating multi-lang sites).

    I have ditched my own datatype, in favour of the Ultimate Picker on my current project, unfortunately I just experienced that the user are unable to deselect all items when an item once has been selected. It would be very nice to have this opportunity, or in other words, I personally need this functionality :) Are there any way that you would consider changing this behaviour or alternatively, can I get my hands on the source?

    Regards
    Mikkel Keller

  7. Chris on August 3rd, 2008

    Hi Tim,
    I have been create a new datatype that I am looking to package up at some point. One thing I have not worked out how to do (and I see from your screen shot you have) is how do I add my own configuration options? E.g. Like your ParentID… in your screen grab above.

    It would be great if you can point me in the right direction, or of you have any code examples I could have a look at?

    Thanks in advance,

    Chris

  8. Thomas Kahn on August 12th, 2008

    Hi Tim! Great work! I submitted a question on the Umbraco forum regarding this add-on, but I don’t know if you have seen it(?) so I thought I’d ask here as well:

    Is it possible to have NO node selected? I’m working on a solution where the user should be able to pick 0, 1, 2 or 3 banners to show on the firstpage and I’m having a hard time getting the 0 (zero) alternative working.

    Is it possible?

    /Thomas K

  9. Nik on September 19th, 2008

    Hi Tim,

    I like the new ultimate picker, but I’m in need of a way to make only certain doc types selectable (my needs are much the same as Petr’s). Any chances to make this happen or let us have a look at the source?

    Nik

  10. Tim Geyssens on September 21st, 2008

    Nik, I mailed you the source.

  11. Nik on September 22nd, 2008

    Tim, haven’t gotten it I’m afraid. Could you please try again? ;) Thanks!

  12. Ricardo Fiel on November 20th, 2008

    Hi. This is great! But on my current project, I need to specify XPath instead of NodeId. Would it be possible to have the source code? Thanks.

  13. Lieven on February 19th, 2009

    Super package Tim!
    Werkt perfect :)

  14. Cem Sisman on February 23rd, 2009

    Can i have the source files please?

  15. Johan Möller on March 12th, 2009

    Hey, did ur “guide” but id like if u coud show what id put in the template to show the content from the page i have chosen with content picker.
    Currently its only showing ID. Cant seem to find any information on how to do this.

  16. David Conlisk on March 19th, 2009

    Nice work Tim - works like a charm!

  17. esunxray on April 28th, 2009

    suggestions:

    1. can parentId be a relative xpath like: $currentPage/ancestor-or-self[@level=1]?
    By this way, multisite can use only one picker to do all,No need to create each picker for each site.

    2. can filter the selected document like: @nodeTypeAlias=’Board’ and data[@alias=’Topic’]=1
    By this way, I can only select Board with Topic=1
    hope to see these in umbraco 4.0.2.

  18. esunxray on April 28th, 2009

    I have submit one issue on codeplex, which include one picture may let you know that I want directly.
    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=22200

    thank you for great work.

  19. Stephan on May 14th, 2009

    Hi Tim!

    Excellent work, I tried to implement an XPath, which seems to be working (at least enough for my needs). But since you shared your code, I thought I should share mine.

    You’re the expert here, so any feed-back is greatly appreciated.

    I added a method,
    private int getParentNodeIdFromXpath(string xpath)
    {
    int retVal = -1;
    if (Int32.TryParse(xpath, out retVal))
    return retVal;
    else
    {
    int currentNodeId = ((umbraco.cms.businesslogic.datatype.DefaultData)_data).NodeId;
    try
    {
    XPathNavigator navigator = content.Instance.XmlContent.CreateNavigator();
    string Expression = xpath.Replace(”$currentPage”, “//node[@id=’” currentNodeId “‘]”);
    retVal = Int32.Parse(navigator.SelectSingleNode(navigator.Compile(Expression)).GetAttribute(”id”, String.Empty));
    }
    catch (Exception ex)
    {
    Log.Add(LogTypes.Error, currentNodeId, ex.ToString());
    }
    return retVal;
    }
    }

    And on the OnInit(EventArgs e) method I changed:
    int parentNodeId = Int32.parse(config[1]);
    to
    int parentNodeId = getParentNodeIdFromXpath(config[1]);

    What do you think?

    BR
    Stephan

Leave a Reply