|
4 | 4 | We highly recommend that you use the [Block List](block-editor/block-list-editor.md) instead.
|
5 | 5 |
|
6 | 6 | Nested Content has been marked as obsolete and development on the property editor has been discontinued.
|
| 7 | + |
| 8 | +[Umbraco Deploy](https://docs.umbraco.com/umbraco-deploy/deployment-workflow/import-export/import-with-migrations) and [uSync migrations](https://github.com/Jumoo/uSyncMigrations) have support for migrating from nested content to the block list. |
7 | 9 | {% endhint %}
|
8 | 10 |
|
9 | 11 | `Alias: Umbraco.NestedContent`
|
@@ -106,7 +108,7 @@ Example:
|
106 | 108 | // Render your content, e.g. item.Value<string>("heading")
|
107 | 109 | }
|
108 | 110 | }
|
109 |
| - |
| 111 | + |
110 | 112 | }
|
111 | 113 | ```
|
112 | 114 |
|
@@ -176,31 +178,31 @@ Afterwards, the entire list needs to be serialized to Json via JsonConvert.
|
176 | 178 | @using Newtonsoft.Json;
|
177 | 179 | @inject IContentService _contentService;
|
178 | 180 |
|
179 |
| - //if the class containing our code inherits SurfaceController, UmbracoApiController, |
| 181 | + //if the class containing our code inherits SurfaceController, UmbracoApiController, |
180 | 182 | //or UmbracoAuthorizedApiController, we can get ContentService from Services namespace
|
181 |
| - var contentService = _contentService; |
| 183 | + var contentService = _contentService; |
182 | 184 | //here we create a new node, and fill out attendeeList afterwards
|
183 |
| - IContent request = contentService.Create("new node", guid, "mydoctype", -1); |
| 185 | + IContent request = contentService.Create("new node", guid, "mydoctype", -1); |
184 | 186 | //our list which will contain nested content
|
185 |
| - var attendees = new List<Dictionary<string, string>>(); |
| 187 | + var attendees = new List<Dictionary<string, string>>(); |
186 | 188 | //participants is our list of attendees - multiple items, good use case for nested content
|
187 |
| - foreach (var person in participants) |
| 189 | + foreach (var person in participants) |
188 | 190 | attendees.Add(new Dictionary<string, string>() {
|
189 | 191 | //this is the only "default" value we need to fill for nested item
|
190 |
| - {"ncContentTypeAlias","attendee"}, |
| 192 | + {"ncContentTypeAlias","attendee"}, |
191 | 193 | {"user_name", person.name},
|
192 | 194 | {"user_email",person.user_email},
|
193 |
| - {"join_time",person.join_time.ToString()}, |
| 195 | + {"join_time",person.join_time.ToString()}, |
194 | 196 | //we convert some properties to String just to be on the safe side
|
195 | 197 | {"leave_time",person.leave_time.ToString()},
|
196 | 198 | {"duration",person.duration.ToString()},
|
197 | 199 | {"phone",person.phone.ToString()}
|
198 | 200 | });
|
199 | 201 | }
|
200 | 202 | //bind the attendees List to attendeeList property on the newly created content node
|
201 |
| - request.SetValue("attendeeList", JsonConvert.SerializeObject(attendees)); |
| 203 | + request.SetValue("attendeeList", JsonConvert.SerializeObject(attendees)); |
202 | 204 | //Save the entire node via ContentService
|
203 |
| - ContentService.SaveAndPublish(request); |
| 205 | + ContentService.SaveAndPublish(request); |
204 | 206 | ```
|
205 | 207 |
|
206 | 208 | In the above sample we iterate through a list of participants (the data for such participants could be coming from an API, for example), and add a new `Dictionary` item for each person in the list.
|
0 commit comments