Copied to clipboard

Flag this post as spam?

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


  • Thomas 315 posts 602 karma points c-trib
    Sep 25, 2018 @ 14:13
    Thomas
    0

    Hey,

    Anyone that can point me in a direction if I want to pull data from children nodes and convert each node data to Json.

    The nodes has different properties.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Sep 25, 2018 @ 14:23
    Jan Skovgaard
    100

    Hi Thomas

    You can do that using WebApi controllers - You can learn more about how that works in Umbraco here https://our.umbraco.com/Documentation/Reference/Routing/WebApi/ - Then you can make some endpoints, which you can consume using Node.

    You could also consider trying the Umbraco headless beta here https://umbraco.com/headless/ but that might not be what you currently need assuming that you need something that is ready for production? You can learn more about Headless in and Node following the documentation here https://our.umbraco.com/documentation/Umbraco-Cloud/Headless/Headless-Node-Client/

    Hope this helps!

    /Jan

  • Thomas 315 posts 602 karma points c-trib
    Sep 25, 2018 @ 14:25
    Thomas
    0

    I have thought of headless. But yeah, need it for production. but thanks, if will give it at look.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Sep 25, 2018 @ 20:01
    Jan Skovgaard
    0

    Hi Thomas

    Ok this is a bit weird...I received an e-mail about a new message on this thread saying "'m not quite sure what to look for on the link you sent Jan ?" - Now I'm puzzled about whether you deleted the post because you figured it out or if there is a bug on the forum. I've seen this behavior 1-2 times before. If you did not delete the message then please let me know since I'm going to try and create an issue about it :-)

    So did you manage to figure it out or do you need me to try and clarify things?

    Cheers,

    Jan

  • Carlos Mosqueda 240 posts 431 karma points
    Oct 02, 2018 @ 17:47
    Carlos Mosqueda
    0

    Is there a way to run Umbraco Headless locally or download the project?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Oct 02, 2018 @ 18:51
    Jan Skovgaard
    0

    Hi Carlos

    No, it's cloud only and it's going to stay that way - I had got an idea that it was at some point going to be possible to download the headless version at a later stage but Niels confirmed that it's not going to happen and be cloud only in this tweet https://twitter.com/thechiefunicorn/status/1043454285265166341 :-)

    But you can achieve pretty much the same using web api so I guess it makes pretty good sense.

    But there's still the old REST API https://github.com/umbraco/UmbracoRestApi but it's discontinued but still usable thought.

    /Jan

  • Carlos Mosqueda 240 posts 431 karma points
    Oct 03, 2018 @ 15:27
    Carlos Mosqueda
    0

    Hi Jan,

    Thanks for responding back.

    I totally understand from a business standpoint the want to keep a product like Headless under wraps and managed by Umbraco and the cloud.

    Put a bug into Niel's ear to think about a local Headless and maybe making it a local license model or something. Could be like the Forms license or something a monthly license model You don't pay your bill, your headless stops working locally too. Or on a per domain basis. $9.99/month or something like that. Best of both worlds. We could get install it locally and Umbraco gets its cut to pay it's developers and keep the lights on.

    Heck, you don't even need to expose the source code for the license or anything like that. Just compile the license DLL, heck, even encrypt it and ping your servers to validate the install, and we can host it on our own hosting for Headless. Just a thought.

    WebAPI could work for us too, but we already do that, but needing to know a the properties, etc., versus Umbraco just outputting the JSON of all content, helps. I guess there is the XML too.

  • Thomas 315 posts 602 karma points c-trib
    Sep 26, 2018 @ 14:36
    Thomas
    0

    Hey Jan :)

    I did write something, but figured it out before you saw the message ! hehe

    I think I almost have it.

    Right now I have this ( thanks to Oleksandr!)

    public class GetDataController : UmbracoApiController
    {
        public class PVSUser
        {
            public string firstname { get; set; }
            public string lastname { get; set; }
            public string phone { get; set; }
            public string altEmail { get; set; }
        }
        // Get send from email and recivere email
        public object GetWidgetsData()
        {
            var contentService = Services.ContentService;
            var widgets = contentService.GetById(1154).Children();
            var test = new List<PropertyCollection>();
            foreach (var widget in widgets)
            {
                test.Add(widget.Properties);
            } 
            return test;
        }
    }
    

    But still have some issue with properties as dropdowns and nested content that are display like this:

    "Value": "[{\"key\":\"e94726ab-2a72-4da6-95d4-646810ea0dcd\",\"name\":\"Patent\",\"ncContentTypeAlias\":\"dropdownNestedContent\",\"typeName\":\"Patent\",\"nestedContent\":\"[{\\\"key\\\":\\\"09c8d5e3-9dd5-42fa-a908-4add8d334395\\\",\\\"name\\\":\\\"lablel 1.1\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"lablel 1.1\\\",\\\"value\\\":\\\"value 1.1\\\"},{\\\"key\\\":\\\"752ecc69-0878-41af-9ce6-1a730c5834bb\\\",\\\"name\\\":\\\"label1.2\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label1.2\\\",\\\"value\\\":\\\"value 1.2\\\"},{\\\"key\\\":\\\"5982a89c-06cb-4564-9d7a-7dfbe051bbba\\\",\\\"name\\\":\\\"label1.3\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label1.3\\\",\\\"value\\\":\\\"value 1.3\\\"}]\",\"checkBoxes\":\"[{\\\"key\\\":\\\"279a3f6c-2b30-4ea2-8973-bcb885c0fc4a\\\",\\\"name\\\":\\\"1.1\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"1.1\\\"},{\\\"key\\\":\\\"c05018ab-1536-4e71-a28d-15b550703f66\\\",\\\"name\\\":\\\"1.2\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"1.2\\\"},{\\\"key\\\":\\\"c1ddb88b-1c2e-4f33-8ba6-c28b49848b2e\\\",\\\"name\\\":\\\"1.3\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"1.3\\\"}]\"},{\"key\":\"42374311-4de4-404f-9145-1df2614421cb\",\"name\":\"Use Model\",\"ncContentTypeAlias\":\"dropdownNestedContent\",\"typeName\":\"Use Model\",\"nestedContent\":\"[{\\\"key\\\":\\\"885733ac-59ae-4666-9f14-b10a832c8d6f\\\",\\\"name\\\":\\\"lable2.1\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"lable2.1\\\",\\\"value\\\":\\\"value 2.1\\\"},{\\\"key\\\":\\\"d6154f74-e7d3-4411-9047-86386f0d6a5f\\\",\\\"name\\\":\\\"label 2.2\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label 2.2\\\",\\\"value\\\":\\\"value 2.2\\\"}]\",\"checkBoxes\":\"[{\\\"key\\\":\\\"8dab2657-d079-480e-b10b-a836e8423233\\\",\\\"name\\\":\\\"2.1\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"2.1\\\"},{\\\"key\\\":\\\"cd606ee6-7ad6-40f2-97e4-9efada661699\\\",\\\"name\\\":\\\"2.2\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"2.2\\\"},{\\\"key\\\":\\\"cdde0ae5-8c28-4517-bcf2-dc51bf88d959\\\",\\\"name\\\":\\\"2.3\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"2.3\\\"}]\"},{\"key\":\"732626e2-b6a8-481b-83b8-7b18a4e3d147\",\"name\":\"Trademark\",\"ncContentTypeAlias\":\"dropdownNestedContent\",\"typeName\":\"Trademark\",\"nestedContent\":\"[{\\\"key\\\":\\\"ae4b110f-5e0e-43dc-9f8c-1e1b98feccf6\\\",\\\"name\\\":\\\"label 3.1\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label 3.1\\\",\\\"value\\\":\\\"value 3.1\\\"},{\\\"key\\\":\\\"e4f15a08-d354-4db4-a7ac-1a41d6ff50a5\\\",\\\"name\\\":\\\"label 3.2\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label 3.2\\\",\\\"value\\\":\\\"value 3.2\\\"}]\",\"checkBoxes\":\"[{\\\"key\\\":\\\"5d7d187e-3804-4445-90da-316341ceba42\\\",\\\"name\\\":\\\"3.1\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"3.1\\\"},{\\\"key\\\":\\\"96588a11-8eb2-4528-be8a-c65c6b0547ef\\\",\\\"name\\\":\\\"3.2\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"3.2\\\"},{\\\"key\\\":\\\"9adab606-ec5d-4522-ac88-c46339e58960\\\",\\\"name\\\":\\\"3.3\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"3.3\\\"}]\"},{\"key\":\"4e479c5d-e4da-44e0-ac94-850b25d16484\",\"name\":\"Design\",\"ncContentTypeAlias\":\"dropdownNestedContent\",\"typeName\":\"Design\",\"nestedContent\":\"[{\\\"key\\\":\\\"112d0e1b-f564-44f7-a796-ea1587a481e8\\\",\\\"name\\\":\\\"label4.1\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label4.1\\\",\\\"value\\\":\\\"value 4.1\\\"},{\\\"key\\\":\\\"4f90ecf7-2d04-4926-9504-2e7e211b25c5\\\",\\\"name\\\":\\\"label 4.2\\\",\\\"ncContentTypeAlias\\\":\\\"labelAndValueItem\\\",\\\"label\\\":\\\"label 4.2\\\",\\\"value\\\":\\\"value4.2\\\"}]\",\"checkBoxes\":\"[{\\\"key\\\":\\\"ffe54bf9-ac04-4e3e-82f5-0b026a871014\\\",\\\"name\\\":\\\"4.1\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"4.1\\\"},{\\\"key\\\":\\\"795611d8-52c6-452c-937a-d1d0bf540c41\\\",\\\"name\\\":\\\"4.2\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"4.2\\\"},{\\\"key\\\":\\\"12ec6bdc-2c38-47c7-9f5b-d859c639e5f9\\\",\\\"name\\\":\\\"4.3\\\",\\\"ncContentTypeAlias\\\":\\\"dropdownItemColection\\\",\\\"dropdownItem\\\":\\\"4.3\\\"}]\"}]",
    
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Oct 02, 2018 @ 18:53
    Jan Skovgaard
    0

    Hi Thomas

    Did you have any luck figuring this one out? I'm not quite sure how to deal with the nesting but surely it must be possible - Unfortunately I have not got my hands dirty with this since I have some backend colleagues doing this for me when needed :)

    But I can try getting some pointers from them unless you already figured it out or someone of the other bright minds in here chime in before that.

    /Jan

  • Thomas 315 posts 602 karma points c-trib
    Jan 24, 2019 @ 10:36
    Thomas
    1

    Hey Jan !

    I did :) (sorry for the late late reply) been stuck with this project)

    var widgets = new List<object>();
    
            foreach (var widget in rawWidgets)
            {
    
                var widgetData = new Dictionary<string, object>();
    
    
                widgetData.Add("WidgetId", widget.Id);
                if (userWidgetsList != null)
                {
                    var CurrentWidget = userWidgetsList.Where(x => x.WidgetId == widget.Id).FirstOrDefault();
                    widgetData.Add("UserLinks", CurrentWidget.Links);
                    widgetData.Add("UserSelected", CurrentWidget.Selected);
                    widgetData.Add("Open", CurrentWidget.Open);
                    widgetData.Add("Tab", CurrentWidget.Tab);
                }
    
                foreach (var value in widget.Properties)
                {
                    if (value.Alias == "pvsMemberRightArea")
                    {
                        List<string> checkboxeValues = new List<string>();
                        foreach (var item in value.Value.ToString().Split(',')) {
                            var preValues = Umbraco.GetPreValueAsString(Int32.Parse(item));
                            checkboxeValues.Add(preValues);  
                        }
                        widgetData.Add(value.Alias, checkboxeValues);
    
                    }
                    else
                    {
                        widgetData.Add(value.Alias, value.Value);
    
                    }
                }
                widgets.Add(widgetData);
            }
    
            return widgets;
    

    I managed to pull all the data from each widget (node) and assigned the doc type alias as key and the content as value :)!

Please Sign in or register to post replies

Write your reply to:

Draft