Copied to clipboard

Flag this post as spam?

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


  • Paul Gower 28 posts 74 karma points
    Jul 08, 2016 @ 22:46
    Paul Gower
    0

    What is the best way to associate a Nested Content node to an Umbraco Member

    My initial thought was to create an Umbraco Relation and associate the Umbraco Member to the Nested Content node. Sadly, I found this form post asking a similar question and as you can see in Matt Bailsford's first response:

    Unfortunately nested content can't have an ID value as they don't truely exist

    I did find the issue/feature that was discussed in the forum post; however, it just adds parent information to the DetachedPublishedContent object and doesn't solve my issue. After reading the form post and the conversations of Hendy Racher, Matt Bailsford and Lee Kelleher in the github pull request, I still don't understand why Nested Content doesn't create a node in Umbraco.

    So basically I need the Nested Content nodes to be created as Umbraco nodes and then stored as a JSON string in the property field. There are a few ways that I see this could be accomplished:

    1. Create a Custom Property Editor for Umbraco Backoffice - I would start with a copy of Nested Content and add code to create the node and attach it before saving the node as a JSON string.

    2. Use the Umbraco Multinode Treepicker control - This control was suggested by Hendy and Jeavon in this forum post as a way to allow a user to select multiple content nodes. Unfortunately going this route would require the user to create the "nested content" nodes first. Then they could associate those "nested content" nodes with the original node. We really like the user experience of the Nested Content control where it allows you to create nodes dynamically in the property editor.

    3. Find a way to associate the Member to the "Nested Content" node - This option would require that I store an association between the top node and it's respective "nested content" node to a Member in Umbraco. There are two issues that come to mind when trying to go this route:

      1. How should I associate the "nested content" node to the Member in a standard Umbraco way? - I immediately think of creating a link table in the database but, in my understanding, that is not the standard Umbraco way. I am still fuzzy about the best way to do this inside Umbraco.
      2. Is there a way to uniquely identify the "nested content" node? - I realize there is a sort order value being set according to the pull request I found above but if the user reorders the nested content items will it change the "nested content" node to member association?

    At this point, I am leaning towards going with option 1, but I wonder if option 3 is a better direction. In reality, I don't believe this is a new problem that someone hasn't already solved, and I hate to create another custom property editor if there is one just like it out there already.

    So if you know of a better way to solve this problem please let me know.

  • Ian 178 posts 752 karma points
    Jul 09, 2016 @ 09:55
    Ian
    0

    Could you elaborate in what way you want to associate a member (assuming front end member not backoffice user) to a nested content node in terms of which member is selected is this via a picker on one of the properties or automated in code?

    A partial answer but would be to create a relation on the document on save and use the comment field specified in irelation to store extra information you need. You could then do all sorts of things if you wanted like create your own extended version of relationservice so hasrelations matches against the comment field for your value before returning true or false and to provide extended querying to get the right relation.

    To assist in this i would probably create a package so as to avoid modifying nested content files which provides a angular http interceptor which intercepts the request for the nested content property editor controller js file and delivers your own slightly modified version which persists the guid ceated anyway on each nested content node during editing into the model.value modified code would also ensure that the guid would only generate a new if it did not already exist on the node

  • Paul Gower 28 posts 74 karma points
    Jul 09, 2016 @ 16:34
    Paul Gower
    0

    Thanks for your quick reply, Ian. You were correct in assuming a front-end member not back office user.

    The way the Member is associated with the Nested Content node is as the user is registering or logging into Umbraco.

    Basically we are building contest functionality on top of Umbraco and a contest can have 1-many prizes (i.e. nested content). The user has to login / register to save the "prize" to their profile.

    There is page where the non-logged in (or logged in) user finds out if they win a prize or not. So my initial design was to grab the ID of the "prize" (aka nested content) and associate that during registration and login; however, as you can see that didn't work as I assumed. This was also where I was going to look at adding an Umbraco relation (however I'm not familiar with them very much at all) to associate the front-end member to the "prize".

  • Ian 178 posts 752 karma points
    Jul 09, 2016 @ 17:56
    Ian
    0

    Before i start it may be worth considering umbraco forms for your situation (not that i've ever used it myself) .If we were to continue with relations and it may be reasonable to do a quick test, see here

    https://github.com/umbraco/UmbracoDocs/blob/master/Reference/Management/Services/RelationService.md

    And here

    https://github.com/umbraco/Umbraco-CMS/blob/980683d25af395244295d9bd95333682325b2678/src/Umbraco.Core/Models/Relation.cs

    Start just by creating a surfacecontroller which creates a relation between a member a demo member with a known id you can hardcode for now and the content node containing all the 'prizes' or any content node if you haven't created it yet in the same way as indicated in the set favourite example in link 1. When creating an instance of the relation class set the comment value to some test string. Then use the methods available for retrieving relations an try adding a linq where constraint to get one with the comment value equal to that set earlier. If that works you know you have the foundations to do the other things i mentioned which allow you to insert the giud value of each selected nested content node into the relation and thereby provide ameans of relating members to nested content nodes

  • Paul Gower 28 posts 74 karma points
    Jul 10, 2016 @ 06:51
    Paul Gower
    0

    Thanks, Ian, I will look into what you suggested.

    However, it seems like a lot of work to not just use my own custom property editor (starting with what nested content has) and actually creating the nodes in Umbraco.

    Do you know of a fundamental reason I shouldn't create the nested content node in Umbraco? It just seems like the quickest way to handle my situation...but maybe I'm not fully understanding what you are suggesting either as I am still learning the Umbraco platform and it's nuances. Please help me understand not only what I need to do but why.

    The reason Umbraco Forms will not work is directly related to how we are using the Umbraco Backoffice. Each content node under "Home" is locked down with specific permissions based on a user (we did this with the Published event mechanism). This means there's a folder for "user1" under the "Home" node and under it there is another "folder" where the contest node is created for that specific user, etc. This has been a headache from the beginning as many plugins I would like to "just use" cannot be because they don't work with such granularity.

  • Ian 178 posts 752 karma points
    Jul 10, 2016 @ 07:44
    Ian
    0

    Dont get me wrong the easiest way is to have real nodes then you can create relationships in the normal way, if you really want to keep it simple nested content or a variant of is just an over complication. If you are creating nested content that creates real nodes the validity and comlexity depends on your implementation. If data for each nested content node is stored on the container node as well as individual (would need to be child nodes) strictly speaking duplicate content is being stored in the xml cache... a bit more bloat.

    If the nested content property editor is just an interface for editing and creating real nodes and saves no data to the container node you are just recreating a fancier version of the list view already in umbraco, which fair do's you may want to do. would you need to find a way to prevent child nodes appearing in the tree otherwise you might need to take into account if the child becomes un published in the ui of your property editor.

    You'll also consider how are you going to visualise or extract the results of these relations at the end of the contest. If you have already selected.a third party package to do this which does exactly what you want then you will probably want to create real nodes.

    It could well just be me overthinking things (which i do) good luck

Please Sign in or register to post replies

Write your reply to:

Draft