Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Jun 02, 2015 @ 01:13
    James
    0

    User created data type

    Hello,

    I am building a site for a charity. The users of the site aren't very technical.

    I want them to be able to add Dog Breeds to a list on a settings node I have created. I then want them to be able to choose from a drop down one of the dog breeds they have entered on a "dog" page.

    Is this possible to do in Umbraco? Can a user add to a list in Umbraco and this populate a data type like a drop down on another page?

    Thanks and kind regards,

     

    J

     

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jun 02, 2015 @ 02:58
    Nathan Woulfe
    0

    Hi James

    We do similar to your requirement- we built a property editor to display content stored in a multi textstring property on a config node. The editor allows users to make a selection from the dropdown and then store a string value against that selection.

    I'd create a new property editor, with two prevalues - one for the id of the config node and one for the alias of the source property. In the editor controller, use contentResource.getById() to look up the node using the id, then get the list of breeds from the node. Once you've got the data, you can use it as the model for the dropdown in your new editor.

    Super simple and dirty Angular to grab the breed list (eg should be breaking out of the loops once a match is found):

    contentResource.getById(nodeId).then(function (resp) {
        var breeds;
        angular.forEach(resp.tabs, function (tab) {
            angular.forEach(tab.properties, function (prop) {
                if (prop.alias === 'dogBreeds') {
                    breeds = prop;
                }
            });
        });
    
        console.log(breeds.value);
    
    });
    

    There's decent documentation around building a property editor available here.

    Hope that helps.

    N

Please Sign in or register to post replies

Write your reply to:

Draft