From 50a1ebc5fd77884576b3713de0b40f0636ac6190 Mon Sep 17 00:00:00 2001 From: Aaron Sadler Date: Thu, 30 May 2024 12:45:37 +0100 Subject: [PATCH] Added a parent property to umbnavitem --- src/UmbNav.Core/Models/UmbNavItem.cs | 3 +++ src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/UmbNav.Core/Models/UmbNavItem.cs b/src/UmbNav.Core/Models/UmbNavItem.cs index ab0aec0..fc8593e 100644 --- a/src/UmbNav.Core/Models/UmbNavItem.cs +++ b/src/UmbNav.Core/Models/UmbNavItem.cs @@ -36,6 +36,9 @@ public class UmbNavItem [JsonProperty("children")] public IEnumerable Children { get; set; } + [JsonIgnore] + public UmbNavItem Parent { get; set; } + [JsonIgnore] public IPublishedContent Content { get; set; } diff --git a/src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs b/src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs index 2af4f59..1c0edcb 100644 --- a/src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs +++ b/src/UmbNav.Core/Services/UmbNavMenuBuilderService.cs @@ -79,6 +79,11 @@ public IEnumerable BuildMenu(IEnumerable items, int leve var children = new List(); if (item.Children != null && item.Children.Any()) { + foreach (var child in item.Children) + { + child.Parent = item; + } + children = item.Children.ToList(); }