Home Umbraco 7 - Get property from one page to another

# Umbraco 7 - Get property from one page to another

Jonas
1#
Jonas Published in 2017-09-12 12:20:52Z
 Im new to umbraco 7 I have a Masterpage - Inside I have 2 Partialviews - HEADER & FOOTER I have 2 subpages that inherites from Masterpage - HOME PAGE & STANDARD PAGE Inside HOME PAGE - Document Type I have a Reletad Links property The code for the Releted Links property is inside a Partialview called Links @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Newtonsoft.Json.Linq @{ if (Model.Content.HasValue("externalLinks") && Model.Content.GetPropertyValue("externalLinks").Length > 2) {
@foreach (var item in Model.Content.GetPropertyValue("externalLinks")) { var linkTarget = item.Value("newWindow") ? "_blank" : null; if (Model.Content.GetPropertyValue("externalLinks").First() == item) {
• @(item.Value("caption"))
• } else {
• @(item.Value("caption"))
• } }
} }  The LINKS partialview is loaded inside the HEADER partialview The code is working fine when navigating to HOME PAGE but If I go to STANDARD PAGE then the Reletad Links property is no loger visible. What can I do to fix this.
Mark
2#
 Instead of referencing the current page (through Model.Content) you'll want to reference the homepage I've added a bit of code to the PartialView to illustrate it, haven't tested it though @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Newtonsoft.Json.Linq @{ // First get the homepage by traversing the Umbraco tree and searching for the homepage node var homepage = Umbraco.TypedContentAtRoot().First().DescendantsOrSelf().FirstOrDefault(x => x.DocumentTypeAlias == "home"); if (homepage != null && homepage.HasValue("externalLinks") && homepage.GetPropertyValue("externalLinks").Length > 2) {
} }