Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
This is the setup:
Then I go into the backend, debug the code:
public Dictionary<string, object> GetPageContent(IPublishedContent publishedContent) { var dictionary = GetSettings(publishedContent.Id, publishedContent.Url(), publishedContent.Properties, publishedContent.ContentType.Alias); return dictionary; } public Dictionary<string, object> GetSettings(int id, string url, IEnumerable<IPublishedProperty> publishedProperties, string docType = "") { var dictionary = new Dictionary<string, object>(); if (publishedProperties == null || !publishedProperties.Any()) return dictionary; foreach (var publishedProperty in publishedProperties) { var propertyType = publishedProperty.PropertyType.EditorAlias; if (propertyType == "Umbraco.MediaPicker3") { if (publishedProperty.GetValue().GetType() == typeof(List<MediaWithCrops>)) { var objectValues = (List<MediaWithCrops>)publishedProperty.GetValue(); var myData = new List<PublishedContentItem>(); foreach (var item in objectValues) { myData.Add(new PublishedContentItem(item)); } dictionary.Add(publishedProperty.Alias, myData); } else if (publishedProperty.GetValue().GetType() == typeof(MediaWithCrops)) { dictionary.Add(publishedProperty.Alias, new PublishedContentItem((MediaWithCrops)publishedProperty.GetValue())); } } else if (propertyType == "Umbraco.ContentPicker") { dictionary.Add(publishedProperty.Alias, new PublishedContentItem((IPublishedContent)publishedProperty.GetValue())); } else if (propertyType == "Umbraco.MultiNodeTreePicker") { var objectValues = (IEnumerable<IPublishedContent>)publishedProperty.GetValue(); var myData = new List<PublishedContentItem>(); foreach (var item in objectValues) { myData.Add(new PublishedContentItem(item)); } dictionary.Add(publishedProperty.Alias, myData); } else if (propertyType == "Umbraco.MultiUrlPicker") { if (publishedProperty.GetValue().GetType() == typeof(IEnumerable<Link>)) { var objectValues = (IEnumerable<Link>)publishedProperty.GetValue(); var myData = new List<MultiUrlPickerModel>(); foreach (var item in objectValues) { myData.Add(new MultiUrlPickerModel(item)); } dictionary.Add(publishedProperty.Alias, myData); } else if (publishedProperty.GetValue().GetType() == typeof(Link)) { dictionary.Add(publishedProperty.Alias, new MultiUrlPickerModel((Link)publishedProperty.GetValue())); } } else if (propertyType == "Umbraco.TinyMCE") { var value = publishedProperty.GetValue(); dictionary.Add(publishedProperty.Alias, value.ToString()); } else if (propertyType == "Umbraco.Label") { // do nothing with a label } else if (propertyType == "Umbraco.BlockList") { var originalItems = (IEnumerable<BlockListItem>)publishedProperty.GetValue(); var customDictionary = new Dictionary<string, object>(); foreach (var blockListItem in originalItems) { var blockListItemDictionary = new Dictionary<string, object>(); blockListItemDictionary.Add("docType", blockListItem.Content.ContentType.Alias); blockListItemDictionary.Add("content", GetSettings(0, "", blockListItem.Content?.Properties)); blockListItemDictionary.Add("settings", GetSettings(0, "", blockListItem.Settings?.Properties)); customDictionary.Add(blockListItem.Content.ContentType.Alias, blockListItemDictionary); } dictionary.Add(publishedProperty.Alias, customDictionary); } else { dictionary.Add(publishedProperty.Alias, publishedProperty.GetValue()); } } if (!string.IsNullOrEmpty(docType) && !dictionary.ContainsKey("docType")) { dictionary.Add("docType", docType); } if (id > 0) { dictionary.Add("id", id); } if (!string.IsNullOrEmpty(url)) { dictionary.Add("url", url); } return dictionary; } }
But it doesn't recognize my newly added block.
What I've tried:
My question is: how can I get this to happen automatically? I've got an intermediate user, who I trust to create new doctypes/compositions.
Full source code: https://github.com/Sibren/Sibbo-Headless-U8
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
ModelsBuilder + Block List not regenerating models without restart
Hi,
This is the setup:
Then I go into the backend, debug the code:
But it doesn't recognize my newly added block.
What I've tried:
My question is: how can I get this to happen automatically? I've got an intermediate user, who I trust to create new doctypes/compositions.
Full source code: https://github.com/Sibren/Sibbo-Headless-U8
is working on a reply...